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" |
19 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
20 #include "net/test/test_server.h" | 19 #include "net/test/test_server.h" |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 class ResourceDispatcherTest : public UITest { | 23 class ResourceDispatcherTest : public UITest { |
25 public: | 24 public: |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 | 271 |
273 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 272 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
274 ASSERT_TRUE(browser_proxy.get()); | 273 ASSERT_TRUE(browser_proxy.get()); |
275 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 274 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
276 ASSERT_TRUE(tab.get()); | 275 ASSERT_TRUE(tab.get()); |
277 | 276 |
278 // Cause the renderer to crash. | 277 // Cause the renderer to crash. |
279 #if defined(OS_WIN) || defined(USE_LINUX_BREAKPAD) | 278 #if defined(OS_WIN) || defined(USE_LINUX_BREAKPAD) |
280 expected_crashes_ = 1; | 279 expected_crashes_ = 1; |
281 #endif | 280 #endif |
282 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutCrashURL))); | 281 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("about:crash"))); |
283 // Wait for browser to notice the renderer crash. | 282 // Wait for browser to notice the renderer crash. |
284 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); | 283 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
285 | 284 |
286 // Navigate to a new cross-site page. The browser should not wait around for | 285 // Navigate to a new cross-site page. The browser should not wait around for |
287 // the old renderer's on{before}unload handlers to run. | 286 // the old renderer's on{before}unload handlers to run. |
288 CheckTitleTest("content-sniffer-test0.html", | 287 CheckTitleTest("content-sniffer-test0.html", |
289 "Content Sniffer Test 0", 1); | 288 "Content Sniffer Test 0", 1); |
290 } | 289 } |
291 #endif // !defined(OS_MACOSX) | 290 #endif // !defined(OS_MACOSX) |
292 | 291 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
377 // Tests that ResourceDispatcherHostRequestInfo is updated correctly on failed | 376 // Tests that ResourceDispatcherHostRequestInfo is updated correctly on failed |
378 // requests, to prevent calling Read on a request that has already failed. | 377 // requests, to prevent calling Read on a request that has already failed. |
379 // See bug 40250. | 378 // See bug 40250. |
380 TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) { | 379 TEST_F(ResourceDispatcherTest, CrossSiteFailedRequest) { |
381 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); | 380 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); |
382 ASSERT_TRUE(browser_proxy.get()); | 381 ASSERT_TRUE(browser_proxy.get()); |
383 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); | 382 scoped_refptr<TabProxy> tab(browser_proxy->GetActiveTab()); |
384 ASSERT_TRUE(tab.get()); | 383 ASSERT_TRUE(tab.get()); |
385 | 384 |
386 // Visit another URL first to trigger a cross-site navigation. | 385 // Visit another URL first to trigger a cross-site navigation. |
387 GURL url(chrome::kChromeUINewTabURL); | 386 GURL url("chrome://newtab"); |
jam
2011/05/24 01:25:47
nit: here too
| |
388 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); | 387 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(url)); |
389 | 388 |
390 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 389 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
391 GURL broken_url("chrome://theme"); | 390 GURL broken_url("chrome://theme"); |
392 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); | 391 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); |
393 | 392 |
394 // Make sure the navigation finishes. | 393 // Make sure the navigation finishes. |
395 std::wstring tab_title; | 394 std::wstring tab_title; |
396 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 395 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
397 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); | 396 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); |
398 } | 397 } |
399 | 398 |
400 } // namespace | 399 } // namespace |
OLD | NEW |