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/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 LoadUrlAndQuitBrowser(NOLISTENERS_HTML, L"nolisteners"); | 232 LoadUrlAndQuitBrowser(NOLISTENERS_HTML, L"nolisteners"); |
233 } | 233 } |
234 | 234 |
235 // Tests closing the browser on a page with an unload listener registered. | 235 // Tests closing the browser on a page with an unload listener registered. |
236 TEST_F(UnloadTest, BrowserCloseUnload) { | 236 TEST_F(UnloadTest, BrowserCloseUnload) { |
237 LoadUrlAndQuitBrowser(UNLOAD_HTML, L"unload"); | 237 LoadUrlAndQuitBrowser(UNLOAD_HTML, L"unload"); |
238 } | 238 } |
239 | 239 |
240 // Tests closing the browser with a beforeunload handler and clicking | 240 // Tests closing the browser with a beforeunload handler and clicking |
241 // OK in the beforeunload confirm dialog. | 241 // OK in the beforeunload confirm dialog. |
| 242 #if !defined(OS_LINUX) |
242 TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) { | 243 TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) { |
243 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 244 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
244 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); | 245 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); |
245 | 246 |
246 CloseBrowserAsync(browser.get()); | 247 CloseBrowserAsync(browser.get()); |
247 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); | 248 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); |
248 WaitForBrowserClosed(); | 249 WaitForBrowserClosed(); |
249 EXPECT_FALSE(IsBrowserRunning()); | 250 EXPECT_FALSE(IsBrowserRunning()); |
250 } | 251 } |
251 | 252 |
252 // Tests closing the browser with a beforeunload handler and clicking | 253 // Tests closing the browser with a beforeunload handler and clicking |
253 // CANCEL in the beforeunload confirm dialog. | 254 // CANCEL in the beforeunload confirm dialog. |
254 TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) { | 255 TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) { |
255 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 256 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
256 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); | 257 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); |
257 | 258 |
258 CloseBrowserAsync(browser.get()); | 259 CloseBrowserAsync(browser.get()); |
259 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_CANCEL); | 260 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_CANCEL); |
260 WaitForBrowserClosed(); | 261 WaitForBrowserClosed(); |
261 EXPECT_TRUE(IsBrowserRunning()); | 262 EXPECT_TRUE(IsBrowserRunning()); |
262 | 263 |
263 CloseBrowserAsync(browser.get()); | 264 CloseBrowserAsync(browser.get()); |
264 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); | 265 ClickModalDialogButton(MessageBoxFlags::DIALOGBUTTON_OK); |
265 WaitForBrowserClosed(); | 266 WaitForBrowserClosed(); |
266 EXPECT_FALSE(IsBrowserRunning()); | 267 EXPECT_FALSE(IsBrowserRunning()); |
267 } | 268 } |
| 269 #endif // !defined(OS_LINUX) |
268 | 270 |
269 // Tests closing the browser with a beforeunload handler that takes | 271 // Tests closing the browser with a beforeunload handler that takes |
270 // two seconds to run. | 272 // two seconds to run. |
271 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnload) { | 273 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnload) { |
272 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_HTML, | 274 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_HTML, |
273 L"twosecondbeforeunload"); | 275 L"twosecondbeforeunload"); |
274 } | 276 } |
275 | 277 |
276 // TODO(estade): On linux, the renderer process doesn't seem to quit and pegs | 278 // TODO(estade): On linux, the renderer process doesn't seem to quit and pegs |
277 // CPU. | 279 // CPU. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 scoped_refptr<TabProxy> main_tab(main_browser_proxy->GetActiveTab()); | 365 scoped_refptr<TabProxy> main_tab(main_browser_proxy->GetActiveTab()); |
364 ASSERT_TRUE(main_tab.get()); | 366 ASSERT_TRUE(main_tab.get()); |
365 std::wstring main_title; | 367 std::wstring main_title; |
366 ASSERT_TRUE(main_tab.get() != NULL); | 368 ASSERT_TRUE(main_tab.get() != NULL); |
367 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); | 369 EXPECT_TRUE(main_tab->GetTabTitle(&main_title)); |
368 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); | 370 EXPECT_EQ(std::wstring(L"only_one_unload"), main_title); |
369 } | 371 } |
370 | 372 |
371 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 373 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
372 // and multiple windows. | 374 // and multiple windows. |
OLD | NEW |