Description
What happened?
When handling window.open, we await
a couple different things.
We also initially keep the Form hidden until the page has loaded and the DOMContentLoaded
event has fired.
When we open a window to a page that requires credentials and would normally show the credentials dialog (since we intercept the BasicAuthenticationRequested
event and set Cancel
to false
), the popup doesn't appear, presumably because when the popup is trying to get shown, the Form isn't visible.
Removing the awaits
works around the issue (maybe there's still some race, but haven't observered any issues yet). In our case, thankfully, it doesn't seem like we need those two awaits
.
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Prerelease (Edge Canary/Dev/Beta)
Runtime Version
136.0.3192.0 canary
SDK Version
3116.0
Framework
Winforms
Operating System
Windows 11
OS Version
24H2 - 26100.3194
Repro steps
Download the WinForms WebView2 sample app.
In BrowserForm::WebView2Control_CoreWebView2InitializationCompleted
, add this.webView2Control.CoreWebView2.NewWindowRequested += NewWindowRequested;
and make that handler:
private async void NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
{
e.Handled = true;
using (e.GetDeferral())
{
Form form = new Form();
form.Size = new Size(800, 600);
WebView2 webView = new WebView2();
await webView.EnsureCoreWebView2Async();
form.Visible = false;
// showing window here fixes this
await Task.Delay(1000);
webView.CoreWebView2.BasicAuthenticationRequested += (object sender, CoreWebView2BasicAuthenticationRequestedEventArgs args) =>
{
args.Cancel = false;
};
form.Controls.Add(webView);
webView.CoreWebView2.DOMContentLoaded += (_, _) =>
{
form.Visible = true;
};
webView.Dock = DockStyle.Fill;
e.NewWindow = webView.CoreWebView2;
}
}
- run the app
- open devtools
- run:
window.open("https://authenticationtest.com/HTTPAuth")
- when the window opens, the credentials dialog doesn't appear
- if you simply remove the
await
of theTask.Delay
line, it starts working - also, if you keep the
await
, but instead make the Form visible before the call, it starts workingForm.Visible = true
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response