| 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 239 |
| 240 CloseBrowserAsync(browser.get()); | 240 CloseBrowserAsync(browser.get()); |
| 241 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK); | 241 ClickModalDialogButton(views::DialogDelegate::DIALOGBUTTON_OK); |
| 242 WaitForBrowserClosed(); | 242 WaitForBrowserClosed(); |
| 243 EXPECT_FALSE(IsBrowserRunning()); | 243 EXPECT_FALSE(IsBrowserRunning()); |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Tests closing the browser with a beforeunload handler that takes | 246 // Tests closing the browser with a beforeunload handler that takes |
| 247 // two seconds to run. | 247 // two seconds to run. |
| 248 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnload) { | 248 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnload) { |
| 249 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 250 // disabled in single process mode like the other tests? | |
| 251 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 252 return; | |
| 253 | |
| 254 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_HTML, | 249 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_HTML, |
| 255 L"twosecondbeforeunload"); | 250 L"twosecondbeforeunload"); |
| 256 } | 251 } |
| 257 | 252 |
| 258 // Tests closing the browser on a page with an unload listener registered where | 253 // Tests closing the browser on a page with an unload listener registered where |
| 259 // the unload handler has an infinite loop. | 254 // the unload handler has an infinite loop. |
| 260 TEST_F(UnloadTest, BrowserCloseInfiniteUnload) { | 255 TEST_F(UnloadTest, BrowserCloseInfiniteUnload) { |
| 261 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 262 // disabled in single process mode like the other tests? | |
| 263 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 264 return; | |
| 265 | |
| 266 LoadUrlAndQuitBrowser(INFINITE_UNLOAD_HTML, L"infiniteunload"); | 256 LoadUrlAndQuitBrowser(INFINITE_UNLOAD_HTML, L"infiniteunload"); |
| 267 } | 257 } |
| 268 | 258 |
| 269 // Tests closing the browser with a beforeunload handler that hangs. | 259 // Tests closing the browser with a beforeunload handler that hangs. |
| 270 TEST_F(UnloadTest, BrowserCloseInfiniteBeforeUnload) { | 260 TEST_F(UnloadTest, BrowserCloseInfiniteBeforeUnload) { |
| 271 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 272 // disabled in single process mode like the other tests? | |
| 273 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 274 return; | |
| 275 | |
| 276 LoadUrlAndQuitBrowser(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload"); | 261 LoadUrlAndQuitBrowser(INFINITE_BEFORE_UNLOAD_HTML, L"infinitebeforeunload"); |
| 277 } | 262 } |
| 278 | 263 |
| 279 // Tests closing the browser on a page with an unload listener registered where | 264 // Tests closing the browser on a page with an unload listener registered where |
| 280 // the unload handler has an infinite loop followed by an alert. | 265 // the unload handler has an infinite loop followed by an alert. |
| 281 TEST_F(UnloadTest, BrowserCloseInfiniteUnloadAlert) { | 266 TEST_F(UnloadTest, BrowserCloseInfiniteUnloadAlert) { |
| 282 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 283 // disabled in single process mode like the other tests? | |
| 284 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 285 return; | |
| 286 | |
| 287 LoadUrlAndQuitBrowser(INFINITE_UNLOAD_ALERT_HTML, L"infiniteunloadalert"); | 267 LoadUrlAndQuitBrowser(INFINITE_UNLOAD_ALERT_HTML, L"infiniteunloadalert"); |
| 288 } | 268 } |
| 289 | 269 |
| 290 // Tests closing the browser with a beforeunload handler that hangs then | 270 // Tests closing the browser with a beforeunload handler that hangs then |
| 291 // pops up an alert. | 271 // pops up an alert. |
| 292 TEST_F(UnloadTest, BrowserCloseInfiniteBeforeUnloadAlert) { | 272 TEST_F(UnloadTest, BrowserCloseInfiniteBeforeUnloadAlert) { |
| 293 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 294 // disabled in single process mode like the other tests? | |
| 295 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 296 return; | |
| 297 | |
| 298 LoadUrlAndQuitBrowser(INFINITE_BEFORE_UNLOAD_ALERT_HTML, | 273 LoadUrlAndQuitBrowser(INFINITE_BEFORE_UNLOAD_ALERT_HTML, |
| 299 L"infinitebeforeunloadalert"); | 274 L"infinitebeforeunloadalert"); |
| 300 } | 275 } |
| 301 | 276 |
| 302 // Tests closing the browser on a page with an unload listener registered where | 277 // Tests closing the browser on a page with an unload listener registered where |
| 303 // the unload handler has an 2 second long loop followed by an alert. | 278 // the unload handler has an 2 second long loop followed by an alert. |
| 304 TEST_F(UnloadTest, BrowserCloseTwoSecondUnloadAlert) { | 279 TEST_F(UnloadTest, BrowserCloseTwoSecondUnloadAlert) { |
| 305 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 306 // disabled in single process mode like the other tests? | |
| 307 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 308 return; | |
| 309 | |
| 310 LoadUrlAndQuitBrowser(TWO_SECOND_UNLOAD_ALERT_HTML, L"twosecondunloadalert"); | 280 LoadUrlAndQuitBrowser(TWO_SECOND_UNLOAD_ALERT_HTML, L"twosecondunloadalert"); |
| 311 } | 281 } |
| 312 | 282 |
| 313 // Tests closing the browser with a beforeunload handler that takes | 283 // Tests closing the browser with a beforeunload handler that takes |
| 314 // two seconds to run then pops up an alert. | 284 // two seconds to run then pops up an alert. |
| 315 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { | 285 TEST_F(UnloadTest, BrowserCloseTwoSecondBeforeUnloadAlert) { |
| 316 // TODO(jabdelmalek): BUG(7933) this started hanging now, should it be | |
| 317 // disabled in single process mode like the other tests? | |
| 318 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | |
| 319 return; | |
| 320 | |
| 321 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML, | 286 LoadUrlAndQuitBrowser(TWO_SECOND_BEFORE_UNLOAD_ALERT_HTML, |
| 322 L"twosecondbeforeunloadalert"); | 287 L"twosecondbeforeunloadalert"); |
| 323 } | 288 } |
| 324 | 289 |
| 325 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 290 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
| 326 // and multiple windows. | 291 // and multiple windows. |
| OLD | NEW |