| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 6 |
| 7 #include "chrome/browser/automation/url_request_mock_http_job.h" | 7 #include "chrome/browser/automation/url_request_mock_http_job.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/test/automation/browser_proxy.h" | 9 #include "chrome/test/automation/browser_proxy.h" |
| 10 #include "chrome/test/ui/ui_test.h" | 10 #include "chrome/test/ui/ui_test.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 LoadUrlAndQuitBrowser(NOLISTENERS_HTML, L"nolisteners"); | 209 LoadUrlAndQuitBrowser(NOLISTENERS_HTML, L"nolisteners"); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Tests closing the browser on a page with an unload listener registered. | 212 // Tests closing the browser on a page with an unload listener registered. |
| 213 TEST_F(UnloadTest, BrowserCloseUnload) { | 213 TEST_F(UnloadTest, BrowserCloseUnload) { |
| 214 LoadUrlAndQuitBrowser(UNLOAD_HTML, L"unload"); | 214 LoadUrlAndQuitBrowser(UNLOAD_HTML, L"unload"); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Tests closing the browser with a beforeunload handler and clicking | 217 // Tests closing the browser with a beforeunload handler and clicking |
| 218 // OK in the beforeunload confirm dialog. | 218 // OK in the beforeunload confirm dialog. |
| 219 TEST_F(UnloadTest, BrowserCloseBeforeUnloadOK) { | 219 TEST_F(UnloadTest, DISABLED_BrowserCloseBeforeUnloadOK) { |
| 220 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 220 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 221 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); | 221 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); |
| 222 | 222 |
| 223 CloseBrowserAsync(browser.get()); | 223 CloseBrowserAsync(browser.get()); |
| 224 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK); | 224 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK); |
| 225 WaitForBrowserClosed(); | 225 WaitForBrowserClosed(); |
| 226 EXPECT_FALSE(IsBrowserRunning()); | 226 EXPECT_FALSE(IsBrowserRunning()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Tests closing the browser with a beforeunload handler and clicking | 229 // Tests closing the browser with a beforeunload handler and clicking |
| 230 // CANCEL in the beforeunload confirm dialog. | 230 // CANCEL in the beforeunload confirm dialog. |
| 231 TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) { | 231 TEST_F(UnloadTest, DISABLED_BrowserCloseBeforeUnloadCancel) { |
| 232 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 232 scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 233 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); | 233 NavigateToDataURL(BEFORE_UNLOAD_HTML, L"beforeunload"); |
| 234 | 234 |
| 235 CloseBrowserAsync(browser.get()); | 235 CloseBrowserAsync(browser.get()); |
| 236 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_CANCEL); | 236 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_CANCEL); |
| 237 WaitForBrowserClosed(); | 237 WaitForBrowserClosed(); |
| 238 EXPECT_TRUE(IsBrowserRunning()); | 238 EXPECT_TRUE(IsBrowserRunning()); |
| 239 | 239 |
| 240 CloseBrowserAsync(browser.get()); | 240 CloseBrowserAsync(browser.get()); |
| 241 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK); | 241 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 // Tests closing the browser with a beforeunload handler that takes | 299 // Tests closing the browser with a beforeunload handler that takes |
| 300 // two seconds to run then pops up an alert. | 300 // two seconds to run then pops up an alert. |
| 301 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { | 301 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { |
| 302 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML, | 302 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML, |
| 303 L"twosecondbeforeunloadalert"); | 303 L"twosecondbeforeunloadalert"); |
| 304 } | 304 } |
| 305 | 305 |
| 306 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 306 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
| 307 // and multiple windows. | 307 // and multiple windows. |
| OLD | NEW |