Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2801813005: Only show a beforeunload dialog if a frame has had a user gesture since its load. (Closed)
Patch Set: one last bit Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index a2dafdd2115acfab9ac53f635f4074ce1ddb5cde..e59fd92e24388367e640533f8a3d9c6eeb3d1eb2 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -3171,6 +3171,15 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient& chrome_client,
if (!GetFrame() || before_unload_event->returnValue().IsNull())
return true;
+ if (!GetFrame()->HasReceivedUserGesture()) {
+ AddConsoleMessage(ConsoleMessage::Create(
+ kJSMessageSource, kErrorMessageLevel,
+ "Blocked attempt to show a 'beforeunload' confirmation panel for a "
+ "frame that never had a user gesture since its load. "
+ "https://www.chromestatus.com/feature/5082396709879808"));
+ return true;
+ }
+
if (did_allow_navigation) {
AddConsoleMessage(ConsoleMessage::Create(
kJSMessageSource, kErrorMessageLevel,
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698