Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem/Bug]: WebView2 closing a window is not calling window.onunload #4872

Open
rajusn273 opened this issue Oct 22, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@rajusn273
Copy link

rajusn273 commented Oct 22, 2024

What happened?

I am using WebView2 control (latest stable release 1.0.2651.64, WebView2 Runtime 127.0.2651.105) in WPF app.
Within the WebView2 control a html form with javascript is loaded, the form uses window.onunload and some other html forms I use window.onbeforeunload to call unlock methods on C# Host objects.
The issue happens when the WPF window is closed and onunload/onbeforeunload javascript methods are not getting called.

I have attached sample application where i launch Test.html inside WebView2, in this form i have subscribed to load, unload and beforeunload. Only load method gets executed which calls a method from HostObject, but on close of the form beforeunload nor unload are getting called.
WebViewEx1.zip

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

127.0.2651.105

SDK Version

1.0.2651.64

Framework

WPF

Operating System

Windows 11

OS Version

10.0.22631

Repro steps

A html form with javascript is loaded in webview2 control hosted inside WPF window, the html form uses js window.onunload and some other html forms I use js window.onbeforeunload to call unlock methods on C# Host objects.
The issue happens when the WPF window is closed and onunload/onbeforeunload javascript methods are not getting called.

Repros in Edge Browser

Yes, issue can be reproduced in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@rajusn273 rajusn273 added the bug Something isn't working label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant