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

Unified Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

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
Index: chrome/browser/devtools/devtools_sanity_browsertest.cc
diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc
index c6dff9b792d345704ae56e901d717f4a25296509..769cc77bdbce698b62573f9b6bf91e8ff967369a 100644
--- a/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -386,6 +386,9 @@ class DevToolsBeforeUnloadTest: public DevToolsSanityTest {
ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(),
"window.addEventListener('beforeunload',"
"function(event) { event.returnValue = 'Foo'; });"));
+ // JavaScript onbeforeunload dialogs require a user gesture.
+ web_contents->GetMainFrame()->ExecuteJavaScriptWithUserGestureForTests(
+ base::string16());
// Disable the hang monitor, otherwise there will be a race between the
// beforeunload dialog and the beforeunload hang timer.
web_contents->GetMainFrame()->DisableBeforeUnloadHangMonitorForTesting();

Powered by Google App Engine
This is Rietveld 408576698