onbeforeunload not working in webview in Chrome App
Reported by
ravil...@gmail.com,
Nov 22 2017
|
||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 Steps to reproduce the problem: 1. create chrome app with webview with src="https://js.do" on window.html 2. change text in left textarea on opened page in webview 3. click on any link to change page in webview What is the expected behavior? If the site opened in the webview uses onbeforeunload event, a confirm dialog should occur when the page changes What went wrong? dialog does not appear Did this work before? N/A Chrome version: 62.0.3202.94 Channel: stable OS Version: 10.0 Flash Version: I first reproduce this bug in nw.js and open issue https://github.com/nwjs/nw.js/issues/6288
,
Nov 27 2017
,
Nov 27 2017
"@Reporter: Could you please provide a sample URL/file which helps us to triage the issue further. Thanks!"
,
Nov 27 2017
Chrome Apps can't open beforeunload dialogs, see issue 179684 and issue 130465 . The best thing we could do is to fire an event listener in the embedder when the guest has a befoerunload event, and then the embedder could confirm/cancel the dialog. It won't work if the user closes the window though, only when navigating. For now, as a workaround you can use the webRequest API to cancel the navigations in the embedder. The usage is: document.querySelector('webview').request.onBeforeRequest.addListener(function(e) { return { cancel: true }; }, {urls: ['<all_urls>']}, ['blocking']); This will cancel all navigations, but you can have code inside the function to inspect the URL and only cancel in some scenarios. See the documentation in https://developer.chrome.com/extensions/webRequest.
,
Dec 9 2017
For lfg@chromium.org "The best thing we could do is to fire an event listener in the embedder when the guest has a befoerunload event, and then the embedder could confirm/cancel the dialog." It's will be perfect. But at this moment webview does not support that event (https://developer.chrome.com/apps/tags/webview). "It won't work if the user closes the window though, only when navigating." This is not so bad. And thank you for workaround. I'll try to use it
,
Dec 10
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Dec 18
Can navigation team look into this?
,
Dec 18
+ekaramad@ and lfg@ who may have some ideas.
,
Dec 19
I've already added my ideas on c#4. I think this is certainly doable, it just needs an owner. |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by manoranj...@chromium.org
, Nov 22 2017