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

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

Issue 2750483007: Only show a beforeunload dialog if a frame has been interacted with. (Closed)
Patch Set: rev Created 3 years, 8 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 43aaf0a8818e7d3dffa5b297bf1756910e408cac..70079aa2cfe24758ac5aebdb69026add88d0fe90 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -3055,6 +3055,14 @@ bool Document::dispatchBeforeUnloadEvent(ChromeClient& chromeClient,
if (!frame() || beforeUnloadEvent->returnValue().isNull())
return true;
+ if (!frame()->hasReceivedUserGesture()) {
+ addConsoleMessage(ConsoleMessage::create(
+ JSMessageSource, ErrorMessageLevel,
+ "Blocked attempt to show a 'beforeunload' confirmation panel for a "
+ "frame without a user gesture."));
+ return true;
+ }
+
if (didAllowNavigation) {
addConsoleMessage(ConsoleMessage::create(
JSMessageSource, ErrorMessageLevel,
« 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