MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: auth popup doesn't appear when Form is initially hidden and the window creation is sufficiently delayed
@venky8951 is already working on this.
Since Mar 21, 2025.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
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
awaitof theTask.Delayline, 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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.