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