Skip to content

[Problem/Bug]: [ Broken] Events NewWindowRequested and WindowCloseRequested are not working together #5261

Open
@DotNet-Fan

Description

@DotNet-Fan

What happened?

Webview2 WindowCloseRequested is not firing at all. This is broken.
We subscribe to NewWindowRequested and WindowCloseRequested events.
In the NewWindowRequested handler, we set the new window parent to the same webview2 instance so that it would show in the same webview2 instance.
This is for the Google social login which would be opened by default as a new window popup.

private void CoreWebView2_NewWindowRequested(CoreWebView2 sender, CoreWebView2NewWindowRequestedEventArgs e)
{

e.Handled = true;
if (sender != null)
e.NewWindow = sender;
}

When the google social login popup is closed after login , the WindowCloseRequested event does not fire at all.
This was working earlier.

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

136.0.3240.92

SDK Version

Microsoft.UI.Xaml.Controls - v 2.8.7

Framework

WinUI2/UWP

Operating System

Windows 11

OS Version

Microsoft Windows [Version 10.0.22631.4317]

Repro steps

In UWP App , add a webview2 control.
Then make sure that Corewebview2 is initialized using EnsureCoreWebView2Async call.
Once initialized in the CoreWebView2Initialized handler subscribe to CoreWebView2.NewWindowRequested and CoreWebView2.WindowCloseRequested event.
In the CoreWebView2.NewWindowRequested handler add the below code

private void CoreWebView2_NewWindowRequested(CoreWebView2 sender, CoreWebView2NewWindowRequestedEventArgs e)
{

e.Handled = true;
if (sender != null)
e.NewWindow = sender;
}

  • Navigate to www.x.com or www.pinterest.com and click on Google login.

  • This opens the google new window in the same instance of webview2.

  • After successful login and close of the popup , the WindowCloseRequested event is not fired .

This was working earlier and the code is broken now.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Worked in 130.0.2849.68

Last working version (if regression)

130.0.2849.68

Metadata

Metadata

Labels

bugSomething isn't workingregressionSomething used to work but doesn't anymore

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions