| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <sstream> | 5 #include <sstream> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 13 #include "chrome/browser/net/url_request_failed_dns_job.h" | 13 #include "chrome/browser/net/url_request_failed_dns_job.h" |
| 14 #include "chrome/browser/net/url_request_mock_http_job.h" | 14 #include "chrome/browser/net/url_request_mock_http_job.h" |
| 15 #include "chrome/common/url_constants.h" | |
| 16 #include "chrome/test/automation/browser_proxy.h" | 15 #include "chrome/test/automation/browser_proxy.h" |
| 17 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
| 18 #include "chrome/test/ui/ui_test.h" | 17 #include "chrome/test/ui/ui_test.h" |
| 18 #include "content/common/test_url_constants.h" |
| 19 #include "content/common/url_constants.h" |
| 19 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 20 #include "net/test/test_server.h" | 21 #include "net/test/test_server.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 class ResourceDispatcherTest : public UITest { | 25 class ResourceDispatcherTest : public UITest { |
| 25 public: | 26 public: |
| 26 void CheckTitleTest(const std::string& file, | 27 void CheckTitleTest(const std::string& file, |
| 27 const std::string& expected_title, | 28 const std::string& expected_title, |
| 28 int expected_navigations) { | 29 int expected_navigations) { |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // Tests that ResourceDispatcherHostRequestInfo is updated correctly on failed | 378 // Tests that ResourceDispatcherHostRequestInfo is updated correctly on failed |
| 378 // requests, to prevent calling Read on a request that has already failed. | 379 // requests, to prevent calling Read on a request that has already failed. |
| 379 // See bug 40250. | 380 // See bug 40250. |
| 380 TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) { | 381 TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) { |
| 381 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 382 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
| 382 ASSERT_TRUE(browser_proxy.get()); | 383 ASSERT_TRUE(browser_proxy.get()); |
| 383 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 384 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
| 384 ASSERT_TRUE(tab.get()); | 385 ASSERT_TRUE(tab.get()); |
| 385 | 386 |
| 386 // Visit another URL first to trigger a cross-site navigation. | 387 // Visit another URL first to trigger a cross-site navigation. |
| 387 GURL url(chrome::kChromeUINewTabURL); | 388 GURL url(chrome::kTestNewTabURL); |
| 388 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); | 389 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
| 389 | 390 |
| 390 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 391 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
| 391 GURL broken_url("chrome://theme"); | 392 GURL broken_url("chrome://theme"); |
| 392 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); | 393 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); |
| 393 | 394 |
| 394 // Make sure the navigation finishes. | 395 // Make sure the navigation finishes. |
| 395 std::wstring tab_title; | 396 std::wstring tab_title; |
| 396 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 397 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
| 397 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); | 398 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); |
| 398 } | 399 } |
| 399 | 400 |
| 400 } // namespace | 401 } // namespace |
| OLD | NEW |