| 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();
|
| +}
|
| +
|
|
|