Skip to content

Commit a07954a

Browse files
HeikoKlareclaude
andcommitted
[Edge] Use getWebView(false) in registerFunctionScript to avoid pumping past NavigationCompleted
Previously, registerFunctionScript called getWebView(true), which pumps the event loop until all pending WebView2 tasks in lastWebViewTask are done — including any Navigate call scheduled by a preceding setUrl(). This caused NavigationCompleted to fire during the pump, before the caller of createFunction() had a chance to register a ProgressListener. The NavigationCompleted event was therefore lost and the ProgressListener never fired, causing tests that register the listener after creating a BrowserFunction to time out. Using getWebView(false) limits the pump to waiting only for WebView2 initialization (webViewWrapperFuture::isDone). The Navigate call is chained on the ForkJoinPool after initialization completes and cannot have run yet when getWebView(false) returns, so NavigationCompleted cannot fire during registerFunctionScript. AddScriptToExecuteOnDocumentCreated is still called on a fully initialized WebView2 instance. The currently loaded document is not affected: super.createFunction() already injects the function script into it via nonBlockingExecute() before registerFunctionScript is entered. See #3254 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 99e5332 commit a07954a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,7 @@ public void createFunction(BrowserFunction function) {
18581858
private void registerFunctionScript(int functionIndex, String functionString) {
18591859
String[] scriptId = new String[1];
18601860
callAndWait(scriptId, completion ->
1861-
webViewProvider.getWebView(true).AddScriptToExecuteOnDocumentCreated(
1861+
webViewProvider.getWebView(false).AddScriptToExecuteOnDocumentCreated(
18621862
stringToWstr(functionString), completion.getAddress()));
18631863
if (scriptId[0] != null) {
18641864
functionScriptIds.put(functionIndex, scriptId[0]);

0 commit comments

Comments
 (0)