Contact emailSummaryThe beforeunload dialog will only be shown if the frame attempting to display it has received a user gesture or user interaction (or if any embedded frame has received such a gesture). (There will be no change to the dispatch of the beforeunload event, just a change to whether the dialog is shown.)MotivationThe beforeunload dialog is an app-modal dialog, which makes it powerful, as it forces the user to drop whatever they're doing and respond to it. It is inherently user-hostile, as the user just gave a navigation request to the browser, but the browser turns around and questions the decision the user made.On one hand, this can be used in a positive way, to warn a user if they are going to be losing data due to a navigation.On the other hand, this can and is abused to annoy users into not leaving a page. While the ability for a page to provide text for the beforeunload dialog was removed a while ago, beforeunload dialogs remain a vector of abuse. In particular, beforeunload dialogs are an ingredient of scam websites, where autoplay audio and threatening text provide a context where the Chromium provided "are you sure you want to leave this page" message becomes worrisome.We want to thread the needle, and only allow good uses of the beforeunload dialog. Good uses of the dialog are those where the user has state that might be lost. If the user never interacted with the page, then the user cannot have any state that might be lost, and therefore we do not risk user data loss by suppressing the dialog in that case.Firefox shipped this in Firefox 44; we would be aligning with them.Interoperability and Compatibility RiskEdge: No signalsFirefox: Shipped in Firefox 44Safari: No signals
Note this should be a "deprecate and remove" since it's a breaking change. +Joe to get it on the radar for the deprecations blog post.
Avi, do you have a test case for this we can try on different browsers?
Do we have any UMA stats to tell us how often this will trigger? If we were just matching Safari and Firefox I wouldn't worry about it
On Sat, Apr 1, 2017 at 9:51 AM, Rick Byers <rby...@chromium.org> wrote:Note this should be a "deprecate and remove" since it's a breaking change. +Joe to get it on the radar for the deprecations blog post.If you prefer to read this intent as"Intent to Deprecate and Remove: beforeunload dialogs without user gesture"I'm OK with that retitling and all that goes with it.
Avi, do you have a test case for this we can try on different browsers?I have been using the w3schools page for testing, and they actually have their beforeunload handler in an iframe.Do we have any UMA stats to tell us how often this will trigger? If we were just matching Safari and Firefox I wouldn't worry about itI don't have stats for this.The reason I proposed doing this at the frame level was to parallel what's planned for the Vibration API. If it makes more sense to do this at the page level, matching Safari and Firefox (which might be desirable for web platform consistency), I would be happy to propose doing that. It would be technically trivial.
If this Intent were officially an Intent to Deprecate and Remove, and it were modified so that a gesture anywhere on the page would qualify any frame to show the beforeunload dialog (matching Firefox and Safari), would I have your LG?
Avi
So that's definitely what Safari and Firefox are doing - looking only at the page level, right? I briefly tried the latest WebKit nightly build on the W3CSchools page and that appeared to be the behavior to me.
We could always split this work into two parts - do the simple thing matching Safari/Firefox now while also adding metrics to see how often iframes are popping unload dialogs without the frame itself having seen a user gesture? WDYT?
LGTM2
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
Forking thread to not confuse with the intent.
I'm very excited to see this change in behavior. Have there been considerations for a longer term removal of beforeunload handlers?
With background sync and the recent fetch keep-alive proposal (on blink-network-dev) it feels like we will have primitives that can address out-of-band data syncs. Robust services will have to deal with killed tabs as well due to browser crashes, OOM killing, power-cycles, etc.
--
For example, you plan to send an urgent e-mail/form, you write/fill it and get distracted and close the tab because you think you sent it. While you do not lose the text itself, others will not get the information in time which may cause a huge unnecessary loss.How would you resolve such a situation without this event?
The difference between unexpected external failures (crash, our of memory...) and explicit user actions (closing a window, closing a tab) is that in the former case, it would probably be pretty clear to the user that the action they were about to perform was not accomplished, while in the latter case, it might be much less clear.
FWIW, I'm happy Blink is considering this change, so +1 from me, even though that really doesn't count for much. :-)
Finally note that there's a vaguely interesting 'gotcha' here regarding modifier keys for shortcuts etc. So if web content is focused and as a user, I press accel-w to close a tab/window/whatever, does the accel (or w) keydown trigger the flag ( https://bugzilla.mozilla.org/show_bug.cgi?id=1345830 ).
-- Firefox (and I guess Chrome, though I'm not familiar with their implementation and I'd be interested if Avi has further details on this!) needs to go talk to the website content process in some way when closing a tab to check if they can really close that tab
if it has a beforeunload handler; this kind of communication either makes UI interactions seem slow
weird mechanics where you proactively go close/hide the tab, but then might need to bring it back once you hear back from the other process that the website didn't want the user to close it.
- per-frame. So now you need mechanics to avoid prompting the user 15 times for websites that abuse it
- can be triggered by web content navigating the window, further causing annoyance/abuse in some situations
Further comments.
On Fri, Apr 7, 2017 at 5:58 PM, Gijs Kruitbosch <gijskru...@gmail.com> wrote:
-- Firefox (and I guess Chrome, though I'm not familiar with their implementation and I'd be interested if Avi has further details on this!) needs to go talk to the website content process in some way when closing a tab to check if they can really close that tab
We track in the browser process whether or not the render processes have pages that have closing event handlers (i.e. beforeunload, unload). Things go much nicer if they don't (we can nuke render processes, etc) but yep, all the downsides.
if it has a beforeunload handler; this kind of communication either makes UI interactions seem slow
Well, not super-slow. There is a one-second timeout. If the browser asks the renderer to fire the beforeunload event, and it doesn't either get a request to show an "are you sure" dialog or an ACK that the event was processed within that timer, navigation proceeds.
- per-frame. So now you need mechanics to avoid prompting the user 15 times for websites that abuse it
We have code to handle this, though I'm not 100% sure it handles all edge cases. (The "stop bugging me" checkbox in the beforeunload dialog works for those situations, though.)
- can be triggered by web content navigating the window, further causing annoyance/abuse in some situations
I literally have a list of things I want to kill about dialogs, and this is already on that list.
Finally note that there's a vaguely interesting 'gotcha' here regarding modifier keys for shortcuts etc. So if web content is focused and as a user, I press accel-w to close a tab/window/whatever, does the accel (or w) keydown trigger the flag ( https://bugzilla.mozilla.org/show_bug.cgi?id=1345830 ).
That possibility was also pointed out to me by Chris Dumez who is working on this for WebKit. In my preliminary tests, those command keys didn't trigger a user gesture. I wonder if the keyboard focus was in the tab at that point, though, but I'm not sure how to get the keyboard focus into the tab to really test the keyboard command without that being something that generates the user gesture.
FWIW, I'm happy Blink is considering this change, so +1 from me, even though that really doesn't count for much. :-)