| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 std::string redirect_script = "window.location='" + | 409 std::string redirect_script = "window.location='" + |
| 410 test_url.possibly_invalid_spec() + "';" + | 410 test_url.possibly_invalid_spec() + "';" + |
| 411 "window.domAutomationController.send(true);"; | 411 "window.domAutomationController.send(true);"; |
| 412 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 412 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 413 browser()->GetActiveWebContents()->GetRenderViewHost(), | 413 browser()->GetActiveWebContents()->GetRenderViewHost(), |
| 414 L"", ASCIIToWide(redirect_script), &success)); | 414 L"", ASCIIToWide(redirect_script), &success)); |
| 415 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 415 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 416 } | 416 } |
| 417 | 417 |
| 418 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 418 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 419 CrossSiteNavigationErrorPage2) { |
| 420 ASSERT_TRUE(test_server()->Start()); |
| 421 |
| 422 GURL url(test_server()->GetURL("files/title2.html")); |
| 423 CheckTitleTest(url, "Title Of Awesomeness", 1); |
| 424 |
| 425 // Navigate to a new cross-site URL that results in an error page. |
| 426 // TODO(creis): If this causes crashes or hangs, it might be for the same |
| 427 // reason as ErrorPageTest::DNSError. See bug 1199491 and |
| 428 // http://crbug.com/22877. |
| 429 GURL failed_url = URLRequestFailedJob::GetMockHttpUrl( |
| 430 net::ERR_NAME_NOT_RESOLVED); |
| 431 |
| 432 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 433 browser(), failed_url, 2); |
| 434 EXPECT_NE(ASCIIToUTF16("Title Of Awesomeness"), |
| 435 browser()->GetActiveWebContents()->GetTitle()); |
| 436 |
| 437 // Repeat navigation. We are testing that this completes. |
| 438 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
| 439 browser(), failed_url, 2); |
| 440 EXPECT_NE(ASCIIToUTF16("Title Of Awesomeness"), |
| 441 browser()->GetActiveWebContents()->GetTitle()); |
| 442 } |
| 443 |
| 444 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 419 CrossOriginRedirectBlocked) { | 445 CrossOriginRedirectBlocked) { |
| 420 // We expect the following URL requests from this test: | 446 // We expect the following URL requests from this test: |
| 421 // 1- http://mock.http/cross-origin-redirect-blocked.html | 447 // 1- http://mock.http/cross-origin-redirect-blocked.html |
| 422 // 2- http://mock.http/redirect-to-title2.html | 448 // 2- http://mock.http/redirect-to-title2.html |
| 423 // 3- http://mock.http/title2.html | 449 // 3- http://mock.http/title2.html |
| 424 // | 450 // |
| 425 // If the redirect in #2 were not blocked, we'd also see a request | 451 // If the redirect in #2 were not blocked, we'd also see a request |
| 426 // for http://mock.http:4000/title2.html, and the title would be different. | 452 // for http://mock.http:4000/title2.html, and the title would be different. |
| 427 CheckTitleTest(GetMockURL("cross-origin-redirect-blocked.html"), | 453 CheckTitleTest(GetMockURL("cross-origin-redirect-blocked.html"), |
| 428 "Title Of More Awesomeness", 2); | 454 "Title Of More Awesomeness", 2); |
| 429 } | 455 } |
| 430 | 456 |
| 431 // Tests that ResourceRequestInfoImpl is updated correctly on failed | 457 // Tests that ResourceRequestInfoImpl is updated correctly on failed |
| 432 // requests, to prevent calling Read on a request that has already failed. | 458 // requests, to prevent calling Read on a request that has already failed. |
| 433 // See bug 40250. | 459 // See bug 40250. |
| 434 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 460 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| 435 CrossSiteFailedRequest) { | 461 CrossSiteFailedRequest) { |
| 436 // Visit another URL first to trigger a cross-site navigation. | 462 // Visit another URL first to trigger a cross-site navigation. |
| 437 GURL url(chrome::kTestNewTabURL); | 463 GURL url(chrome::kTestNewTabURL); |
| 438 ui_test_utils::NavigateToURL(browser(), url); | 464 ui_test_utils::NavigateToURL(browser(), url); |
| 439 | 465 |
| 440 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 466 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
| 441 GURL broken_url("chrome://theme"); | 467 GURL broken_url("chrome://theme"); |
| 442 CheckTitleTest(broken_url, "chrome://theme/ is not available", 1); | 468 CheckTitleTest(broken_url, "chrome://theme/ is not available", 1); |
| 443 } | 469 } |
| OLD | NEW |