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