New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 787881 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 2
Type: Feature



Sign in to add a comment

onbeforeunload not working in webview in Chrome App

Reported by ravil...@gmail.com, Nov 22 2017

Issue description

UserAgent: 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
 
Labels: Needs-Triage-M62
Components: -Blink Platform>Apps>BrowserTag Blink>Loader
Cc: vamshi.k...@techmahindra.com
Labels: Triaged-ET Needs-Feedback
"@Reporter: Could you please provide a sample URL/file which helps us to triage the issue further.

Thanks!"

Comment 4 by lfg@chromium.org, Nov 27 2017

Labels: -Needs-Feedback -Arch-x86_64 -Needs-Triage-M62 OS-Chrome OS-Linux OS-Mac
Status: Available (was: Unconfirmed)
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.

Comment 5 by ravil...@gmail.com, 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
Project Member

Comment 6 by sheriffbot@chromium.org, Dec 10

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
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
Components: -Blink>Loader UI>Browser>Navigation
Can navigation team look into this?
Cc: ekaramad@chromium.org wjmaclean@chromium.org lfg@chromium.org
+ekaramad@ and lfg@ who may have some ideas.
Labels: -Type-Bug -Hotlist-Recharge-Cold Type-Feature
Status: Available (was: Untriaged)
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