OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
8 #include "chrome/browser/net/url_request_mock_http_job.h" | 8 #include "chrome/browser/net/url_request_mock_http_job.h" |
9 #include "chrome/browser/view_ids.h" | 9 #include "chrome/browser/view_ids.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/test/automation/browser_proxy.h" | 11 #include "chrome/test/automation/browser_proxy.h" |
12 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
13 #include "chrome/test/automation/window_proxy.h" | 13 #include "chrome/test/automation/window_proxy.h" |
14 #include "chrome/test/ui/ui_test.h" | 14 #include "chrome/test/ui/ui_test.h" |
15 #include "net/url_request/url_request_unittest.h" | 15 #include "net/url_request/url_request_unittest.h" |
16 #include "views/event.h" | 16 #include "views/event.h" |
17 | 17 |
18 #if defined(OS_LINUX) | 18 #if defined(OS_LINUX) |
19 // http://crbug.com/47575 | 19 // http://crbug.com/47575 |
20 #define MAYBE_BrowserCloseNoUnloadListeners \ | 20 #define MAYBE_BrowserCloseNoUnloadListeners \ |
21 DISABLED_BrowserCloseNoUnloadListeners | 21 DISABLED_BrowserCloseNoUnloadListeners |
22 #define MAYBE_BrowserCloseUnload DISABLED_BrowserCloseUnload | 22 #define MAYBE_BrowserCloseUnload DISABLED_BrowserCloseUnload |
| 23 #define MAYBE_BrowserCloseTwoSecondBeforeUnload \ |
| 24 DISABLED_BrowserCloseTwoSecondBeforeUnload |
23 #else | 25 #else |
24 #define MAYBE_BrowserCloseNoUnloadListeners BrowserCloseNoUnloadListeners | 26 #define MAYBE_BrowserCloseNoUnloadListeners BrowserCloseNoUnloadListeners |
25 #define MAYBE_BrowserCloseUnload BrowserCloseUnload | 27 #define MAYBE_BrowserCloseUnload BrowserCloseUnload |
| 28 #define MAYBE_BrowserCloseTwoSecondBeforeUnload \ |
| 29 BrowserCloseTwoSecondBeforeUnload |
26 #endif | 30 #endif |
27 | 31 |
28 const std::string NOLISTENERS_HTML = | 32 const std::string NOLISTENERS_HTML = |
29 "<html><head><title>nolisteners</title></head><body></body></html>"; | 33 "<html><head><title>nolisteners</title></head><body></body></html>"; |
30 | 34 |
31 const std::string UNLOAD_HTML = | 35 const std::string UNLOAD_HTML = |
32 "<html><head><title>unload</title></head><body>" | 36 "<html><head><title>unload</title></head><body>" |
33 "<script>window.onunload=function(e){}</script></body></html>"; | 37 "<script>window.onunload=function(e){}</script></body></html>"; |
34 | 38 |
35 const std::string BEFORE_UNLOAD_HTML = | 39 const std::string BEFORE_UNLOAD_HTML = |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 | 342 |
339 NavigateToDataURL(INNER_FRAME_WITH_FOCUS_HTML, L"innerframewithfocus"); | 343 NavigateToDataURL(INNER_FRAME_WITH_FOCUS_HTML, L"innerframewithfocus"); |
340 | 344 |
341 CloseBrowserAsync(browser.get()); | 345 CloseBrowserAsync(browser.get()); |
342 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); | 346 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); |
343 WaitForBrowserClosed(); | 347 WaitForBrowserClosed(); |
344 } | 348 } |
345 | 349 |
346 // Tests closing the browser with a beforeunload handler that takes | 350 // Tests closing the browser with a beforeunload handler that takes |
347 // two seconds to run. | 351 // two seconds to run. |
348 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnload) { | 352 TEST_F(UnloadTest, MAYBE_BrowserCloseTwoSecondBeforeUnload) { |
349 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_HTML, | 353 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_HTML, |
350 L"twosecondbeforeunload"); | 354 L"twosecondbeforeunload"); |
351 } | 355 } |
352 | 356 |
353 // Tests closing the browser on a page with an unload listener registered where | 357 // Tests closing the browser on a page with an unload listener registered where |
354 // the unload handler has an infinite loop. | 358 // the unload handler has an infinite loop. |
355 TEST_F(UnloadTest, BrowserCloseInfiniteUnload) { | 359 TEST_F(UnloadTest, BrowserCloseInfiniteUnload) { |
356 // Tests makes no sense in single-process mode since the renderer is hung. | 360 // Tests makes no sense in single-process mode since the renderer is hung. |
357 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | 361 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
358 return; | 362 return; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_timeout_ms())); | 451 ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_timeout_ms())); |
448 scoped_refptr<TabProxy> main_tab(browser->GetActiveTab()); | 452 scoped_refptr<TabProxy> main_tab(browser->GetActiveTab()); |
449 ASSERT_TRUE(main_tab.get()); | 453 ASSERT_TRUE(main_tab.get()); |
450 std::wstring main_title; | 454 std::wstring main_title; |
451 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); | 455 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); |
452 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); | 456 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); |
453 } | 457 } |
454 | 458 |
455 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 459 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
456 // and multiple windows. | 460 // and multiple windows. |
OLD | NEW |