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

Unified Diff: chrome/browser/browser_browsertest.cc

Issue 246080: Prevents a duplicate beforeunload dialog after window.close().... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | « no previous file | chrome/browser/renderer_host/render_view_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_browsertest.cc
===================================================================
--- chrome/browser/browser_browsertest.cc (revision 27884)
+++ chrome/browser/browser_browsertest.cc (working copy)
@@ -23,6 +23,9 @@
"<script>window.onbeforeunload=function(e){return 'foo'}</script>"
"</body></html>";
+const std::wstring OPEN_NEW_BEFOREUNLOAD_PAGE =
+ L"w=window.open(); w.onbeforeunload=function(e){return 'foo'};";
+
namespace {
// Given a page title, returns the expected window caption string.
@@ -161,3 +164,23 @@
browser()->GetSelectedTabContents()->render_view_host()->
ExecuteJavascriptInWebFrame(L"", L"onbeforeunload=null;");
}
+
+// Test for crbug.com/11647. A page closed with window.close() should not have
+// two beforeunload dialogs shown.
+IN_PROC_BROWSER_TEST_F(BrowserTest, SingleBeforeUnloadAfterWindowClose) {
+ browser()->GetSelectedTabContents()->render_view_host()->
+ ExecuteJavascriptInWebFrame(L"", OPEN_NEW_BEFOREUNLOAD_PAGE);
+
+ // Close the new window with JavaScript, which should show a single
+ // beforeunload dialog. Then show another alert, to make it easy to verify
+ // that a second beforeunload dialog isn't shown.
+ browser()->GetTabContentsAt(0)->render_view_host()->
+ ExecuteJavascriptInWebFrame(L"", L"w.close(); alert('bar');");
+ AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
+ alert->AcceptWindow();
+
+ alert = ui_test_utils::WaitForAppModalDialog();
+ EXPECT_FALSE(alert->is_before_unload_dialog());
+ alert->AcceptWindow();
+}
+
« no previous file with comments | « no previous file | chrome/browser/renderer_host/render_view_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698