WV2PreloadRepro.zip
What happened?
A script registered with AddScriptToExecuteOnDocumentCreatedAsync on a new window (during NewWindowRequested, before args.NewWindow is set) does not run on that window's about:blank document on the Canary runtime. It runs fine on the stable runtime, so this is a regression.
In my app, when a page calls window.open(), I inject an init script into the new window this way and the script postMessages back when it's ready. On Canary the script never runs, the message never arrives, and my app hangs waiting for it.
Importance
Blocking. My app's basic functions are not working due to this issue.
Runtime Channel
Prerelease (Edge Canary/Dev/Beta)
Runtime Version
150.0.4072.0
SDK Version
1.0.3485.44
Framework
Winforms
Operating System
Windows 11
OS Version
26200.8457
Repro steps
A minimal, self-contained repro is attached (WV2PreloadRepro).
It:
- Opens a page that calls window.open('about:blank').
- Handles NewWindowRequested: takes a deferral, creates the new window's CoreWebView2 via CreateCoreWebView2ControllerAsync (so it doesn't navigate on its own), registers a document-created script on it, then sets args.NewWindow and completes the deferral.
- WebView2 navigates the new window to about:blank, which should fire the registered document-created script.
- The script sets window.__initRan = true and postMessages back to the host.
To run:
dotnet run # stable runtime
dotnet run -- canary # Canary runtime (must be installed)
The repro selects the channel via CoreWebView2ChannelSearchKind.LeastStable (Canary) vs MostStable (stable). Each run logs the resolved runtime version, whether WebMessageReceived fired, the new window's window.__initRan value, and a PASS/FAIL result.
Expected behavior
The registered document-created script runs on the new window's about:blank document on both runtimes, WebMessageReceived fires and window.__initRan === true — as it does on stable.
Actual behavior
- Stable: WebMessageReceived fires, window.__initRan === true → RESULT: PASS
- Canary: WebMessageReceived never fires, window.__initRan is not true → RESULT: FAIL
Additional context
- The new window's CoreWebView2 is created with CreateCoreWebView2ControllerAsync so it does not navigate before the script is registered; the only document creation after registration is the about:blank navigation WebView2 performs when args.NewWindow is set.
- ExecuteScriptAsync (a separate channel) still works against the new window under Canary, that's how window.__initRan is read back even when the document-created script never ran. So the window and its document exist; only the registered document-created script fails to run.
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Regression in newer Runtime
Last working version (if regression)
Runtime 148.0.3967.96
WV2PreloadRepro.zip
What happened?
A script registered with AddScriptToExecuteOnDocumentCreatedAsync on a new window (during NewWindowRequested, before args.NewWindow is set) does not run on that window's about:blank document on the Canary runtime. It runs fine on the stable runtime, so this is a regression.
In my app, when a page calls window.open(), I inject an init script into the new window this way and the script postMessages back when it's ready. On Canary the script never runs, the message never arrives, and my app hangs waiting for it.
Importance
Blocking. My app's basic functions are not working due to this issue.
Runtime Channel
Prerelease (Edge Canary/Dev/Beta)
Runtime Version
150.0.4072.0
SDK Version
1.0.3485.44
Framework
Winforms
Operating System
Windows 11
OS Version
26200.8457
Repro steps
A minimal, self-contained repro is attached (WV2PreloadRepro).
It:
To run:
The repro selects the channel via CoreWebView2ChannelSearchKind.LeastStable (Canary) vs MostStable (stable). Each run logs the resolved runtime version, whether WebMessageReceived fired, the new window's window.__initRan value, and a PASS/FAIL result.
Expected behavior
The registered document-created script runs on the new window's about:blank document on both runtimes, WebMessageReceived fires and window.__initRan === true — as it does on stable.
Actual behavior
Additional context
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
Regression in newer Runtime
Last working version (if regression)
Runtime 148.0.3967.96