You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have ran into an issue on the 2021-09 release where BrowserFunctions are sometimes undefined in the window when using the Edge browser. This looks to be caused by some sort of race condition that occurs when a Browser has BrowserFunctions registered and its URL is set quickly after it is constructed. When more time is added between the construction of the Browser instance and registering browser functions/setting the URL, the error occurs far less frequently. This issue is unique to Edge as the code works without issue when using IE.
From briefly looking over the code and documented changes, this looks to be related to execute(String script) no longer being synchronous when using the Edge browser implementation. When adding a browser function to the window, createFunction(BrowserFunction function) calls nonBlockingExecute(String script) to execute the JS used to define the browser function in the window. The browser's own implementation of execute(String script) is then called to run the script. This then asynchronously adds the browser function to the window.
It might be possible to correct this by adding an override implementation of createFunction(BrowserFunction function) to Edge.java and using a similar strategy as the Edge evaluate(String script) does to wait for the callback to report completion before continuing.
A good alternative would also be adding support for Window.postMessage() as mentioned in the Potential API addons. With asynchronous options being commonly preferred in web development the synchronous behavior of browser functions will likely become harder to maintain and less desired as time goes on.
The text was updated successfully, but these errors were encountered:
For Edge, the current BrowserFunction injection mechanism is indeed suboptimal. It was inherited from the MSIE implementation, which is a lot less asynchronous. The proper way to inject BrowserFunctions is to use script injection API (AddScriptToExecuteOnDocumentCreated). This API, in theory, guarantees that the injected code runs before any page scripts, although the call itself is asynchronous and might race with page navigation.
Also, Bug 578016 might be the same bug or at least be fixed together with this one.
I have ran into an issue on the 2021-09 release where BrowserFunctions are sometimes undefined in the window when using the Edge browser. This looks to be caused by some sort of race condition that occurs when a Browser has BrowserFunctions registered and its URL is set quickly after it is constructed. When more time is added between the construction of the Browser instance and registering browser functions/setting the URL, the error occurs far less frequently. This issue is unique to Edge as the code works without issue when using IE.
From briefly looking over the code and documented changes, this looks to be related to execute(String script) no longer being synchronous when using the Edge browser implementation. When adding a browser function to the window, createFunction(BrowserFunction function) calls nonBlockingExecute(String script) to execute the JS used to define the browser function in the window. The browser's own implementation of execute(String script) is then called to run the script. This then asynchronously adds the browser function to the window.
It might be possible to correct this by adding an override implementation of createFunction(BrowserFunction function) to Edge.java and using a similar strategy as the Edge evaluate(String script) does to wait for the callback to report completion before continuing.
A good alternative would also be adding support for Window.postMessage() as mentioned in the Potential API addons. With asynchronous options being commonly preferred in web development the synchronous behavior of browser functions will likely become harder to maintain and less desired as time goes on.
The text was updated successfully, but these errors were encountered: