OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/test/test_timeouts.h" | 6 #include "base/test/test_timeouts.h" |
7 #include "chrome/browser/ui/view_ids.h" | 7 #include "chrome/browser/ui/view_ids.h" |
8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.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" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 CloseBrowserAsync(browser.get()); | 309 CloseBrowserAsync(browser.get()); |
310 ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK); | 310 ClickModalDialogButton(ui::MessageBoxFlags::DIALOGBUTTON_OK); |
311 | 311 |
312 int exit_code = -1; | 312 int exit_code = -1; |
313 ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit( | 313 ASSERT_TRUE(launcher_->WaitForBrowserProcessToQuit( |
314 TestTimeouts::action_max_timeout_ms(), &exit_code)); | 314 TestTimeouts::action_max_timeout_ms(), &exit_code)); |
315 EXPECT_EQ(0, exit_code); // Expect a clean shutdown. | 315 EXPECT_EQ(0, exit_code); // Expect a clean shutdown. |
316 } | 316 } |
317 | 317 |
| 318 // Tests terminating the browser with a beforeunload handler. |
| 319 // Currently only ChromeOS shuts down gracefully. |
| 320 #if defined(OS_CHROMEOS) |
| 321 TEST_F(UnloadTest, BrowserTerminateBeforeUnload) { |
| 322 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 323 ASSERT_TRUE(browser.get()); |
| 324 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); |
| 325 TerminateBrowser(); |
| 326 VerifyCleanExit(); |
| 327 } |
| 328 #endif |
| 329 |
318 #if defined(OS_LINUX) | 330 #if defined(OS_LINUX) |
319 // Fails sometimes on Linux valgrind. http://crbug.com/45675 | 331 // Fails sometimes on Linux valgrind. http://crbug.com/45675 |
320 #define MAYBE_BrowserCloseWithInnerFocusedFrame \ | 332 #define MAYBE_BrowserCloseWithInnerFocusedFrame \ |
321 FLAKY_BrowserCloseWithInnerFocusedFrame | 333 FLAKY_BrowserCloseWithInnerFocusedFrame |
322 #else | 334 #else |
323 #define MAYBE_BrowserCloseWithInnerFocusedFrame \ | 335 #define MAYBE_BrowserCloseWithInnerFocusedFrame \ |
324 BrowserCloseWithInnerFocusedFrame | 336 BrowserCloseWithInnerFocusedFrame |
325 #endif | 337 #endif |
326 | 338 |
327 // Tests closing the browser and clicking OK in the beforeunload confirm dialog | 339 // Tests closing the browser and clicking OK in the beforeunload confirm dialog |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 ASSERT_TRUE(browser->WaitForTabCountToBecome(1)); | 477 ASSERT_TRUE(browser->WaitForTabCountToBecome(1)); |
466 scoped_refptr<TabProxy> main_tab(browser->GetActiveTab()); | 478 scoped_refptr<TabProxy> main_tab(browser->GetActiveTab()); |
467 ASSERT_TRUE(main_tab.get()); | 479 ASSERT_TRUE(main_tab.get()); |
468 std::wstring main_title; | 480 std::wstring main_title; |
469 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); | 481 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); |
470 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); | 482 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); |
471 } | 483 } |
472 | 484 |
473 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 485 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
474 // and multiple windows. | 486 // and multiple windows. |
OLD | NEW |