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

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: test fix 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
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 29d87cd9bc423ddfed4d97d7774bdf1194e67eaf..4f859da97178eb940fd12f914aece10c98c62e68 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,

Powered by Google App Engine
This is Rietveld 408576698