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

Issue 707007 link

Starred by 10 users

Issue metadata

Status: Fixed
Owner:
Closed: Jun 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 3
Type: Launch-OWP
Launch-Accessibility: ----
Launch-Exp-Leadership: ----
Launch-Leadership: ----
Launch-Legal: ----
Launch-M-Approved: ----
Launch-M-Target: ----
Launch-Privacy: ----
Launch-Security: ----
Launch-Test: ----
Launch-UI: ----
Rollout-Type: ----

Blocked on:
issue 709765



Sign in to add a comment

Require user gesture for beforeunload dialogs

Project Member Reported by a...@chromium.org, Mar 30 2017

Issue description

Summary
The 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.)

Motivation
The 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.

The spec has guidance in this area (https://html.spec.whatwg.org/multipage/browsers.html#unloading-documents):

"The user agent is encouraged to avoid asking the user for confirmation if it judges that doing so would be annoying, deceptive, or pointless. A simple heuristic might be that if the user has not interacted with the document, the user agent would not ask for confirmation before unloading it."

Firefox shipped this in Firefox 44; we would be aligning with them.

Interoperability and Compatibility Risk

Edge: No signals
Firefox: Shipped in Firefox 44 (https://bugzilla.mozilla.org/show_bug.cgi?id=636905)
Safari: In development (https://trac.webkit.org/changeset/214277/webkit), though their version currently is page-oriented rather than frame oriented.
Web developers: No signals

Ongoing technical constraints
None.

Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
 

Comment 1 by a...@chromium.org, Mar 30 2017

Description: Show this description

Comment 2 by a...@chromium.org, Apr 1 2017

Description: Show this description

Comment 3 by a...@chromium.org, Apr 6 2017

Description: Show this description

Comment 4 by a...@chromium.org, Apr 6 2017

Cc: creis@chromium.org a...@chromium.org nasko@chromium.org dcheng@chromium.org
 Issue 692224  has been merged into this issue.

Comment 5 by a...@chromium.org, Apr 8 2017

Blockedon: 709765
This would break my extension. I use beforeunload in a pinned tab to provide confirmation when closing multiple tabs. Can extension pages and content scripts be excluded from this change?
Project Member

Comment 7 by bugdroid1@chromium.org, May 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/336125f7f83771a5fc4a44affdd66327549ab1d7

commit 336125f7f83771a5fc4a44affdd66327549ab1d7
Author: avi <avi@chromium.org>
Date: Sat May 06 22:25:40 2017

Only show a beforeunload dialog if a frame has had a user gesture since its load.

https://www.chromestatus.com/feature/5082396709879808

BUG= 707007 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2801813005
Cr-Commit-Position: refs/heads/master@{#469891}

[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/android_webview/javatests/src/org/chromium/android_webview/test/WebViewModalDialogOverrideTest.java
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/chrome/android/javatests/src/org/chromium/chrome/browser/ModalDialogTest.java
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/chrome/browser/devtools/devtools_sanity_browsertest.cc
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/chrome/browser/lifetime/browser_close_manager_browsertest.cc
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/chrome/browser/ui/browser_browsertest.cc
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/chrome/browser/unload_browsertest.cc
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/content/browser/frame_host/render_frame_host_impl_browsertest.cc
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/content/browser/web_contents/web_contents_impl.h
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/content/public/test/browser_test_utils.cc
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/content/public/test/browser_test_utils.h
[add] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/content/test/data/render_frame_host/beforeunload.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/fast/events/before-unload-reloads.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/fast/events/before-unload-returnValue.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/fast/loader/form-submission-after-beforeunload-cancel.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/fast/loader/resources/iframe-with-beforeunload.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/fast/loader/show-only-one-beforeunload-dialog.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/http/tests/misc/resources/reentrant-beforeunload-helper.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html
[modify] https://crrev.com/336125f7f83771a5fc4a44affdd66327549ab1d7/third_party/WebKit/Source/core/dom/Document.cpp

Comment 8 by a...@chromium.org, Jun 27 2017

Status: Fixed (was: Assigned)
It looks like this is also preventing the beforeunload dialog box from showing when a) the beforeunload handler is installed on a top-level window and b) user gestures are occurring in an iframe stretched 100%/100% across the main window's body.

This would seem to be contrary to the statement above of "(or if any embedded frame has received such a gesture)".

Bug here: https://bugs.chromium.org/p/chromium/issues/detail?id=738555

Sign in to add a comment