| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "app/message_box_flags.h" |
| 6 #include "base/gfx/rect.h" |
| 7 #include "chrome/app/chrome_dll_resource.h" |
| 8 #include "chrome/browser/view_ids.h" |
| 9 #include "chrome/test/ui/ui_test.h" |
| 10 #include "chrome/test/automation/automation_proxy.h" |
| 11 #include "chrome/test/automation/browser_proxy.h" |
| 12 #include "chrome/test/automation/tab_proxy.h" |
| 13 #include "chrome/test/automation/window_proxy.h" |
| 14 #include "views/event.h" |
| 15 |
| 16 class FastShutdown : public UITest { |
| 17 }; |
| 18 |
| 19 // This tests for a previous error where uninstalling an onbeforeunload |
| 20 // handler would enable fast shutdown even if an onUnload handler still |
| 21 // existed. |
| 22 TEST_F(FastShutdown, SlowTermination) { |
| 23 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 24 ASSERT_TRUE(browser.get()); |
| 25 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 26 ASSERT_TRUE(window.get()); |
| 27 |
| 28 // This page has an unload handler. |
| 29 GURL url = GetTestUrl(L"fast_shutdown", L"on_unloader.html"); |
| 30 NavigateToURLBlockUntilNavigationsComplete(url, 1); |
| 31 gfx::Rect bounds; |
| 32 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &bounds, true)); |
| 33 // This click will launch a popup which has a before unload handler. |
| 34 ASSERT_TRUE(window->SimulateOSClick(bounds.CenterPoint(), |
| 35 views::Event::EF_LEFT_BUTTON_DOWN)); |
| 36 ASSERT_TRUE(browser->WaitForTabCountToBecome(2, action_timeout_ms())); |
| 37 // Close the tab, removing the one and only before unload handler. |
| 38 scoped_refptr<TabProxy> tab(browser->GetTab(1)); |
| 39 ASSERT_TRUE(tab->Close(true)); |
| 40 |
| 41 // Close the browser. We should launch the unload handler, which is an |
| 42 // alert(). |
| 43 ASSERT_TRUE(browser->ApplyAccelerator(IDC_CLOSE_WINDOW)); |
| 44 ASSERT_TRUE(automation()->WaitForAppModalDialog(action_timeout_ms())); |
| 45 automation()->ClickAppModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); |
| 46 } |
| OLD | NEW |