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 <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/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
14 #include "chrome/test/automation/automation_proxy.h" | 14 #include "chrome/test/automation/automation_proxy.h" |
15 #include "chrome/test/automation/browser_proxy.h" | 15 #include "chrome/test/automation/browser_proxy.h" |
16 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
17 #include "chrome/test/ui/ui_test.h" | 17 #include "chrome/test/ui/ui_test.h" |
18 #include "content/common/test_url_constants.h" | 18 #include "content/common/test_url_constants.h" |
19 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
20 #include "content/test/net/url_request_failed_dns_job.h" | 20 #include "content/test/net/url_request_failed_job.h" |
21 #include "content/test/net/url_request_mock_http_job.h" | 21 #include "content/test/net/url_request_mock_http_job.h" |
| 22 #include "net/base/net_errors.h" |
22 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
23 #include "net/test/test_server.h" | 24 #include "net/test/test_server.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 class ResourceDispatcherTest : public UITest { | 28 class ResourceDispatcherTest : public UITest { |
28 public: | 29 public: |
29 void CheckTitleTest(const std::string& file, | 30 void CheckTitleTest(const std::string& file, |
30 const std::string& expected_title, | 31 const std::string& expected_title, |
31 int expected_navigations) { | 32 int expected_navigations) { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 std::wstring tab_title; | 345 std::wstring tab_title; |
345 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 346 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
346 EXPECT_EQ(L"set cookie on unload", tab_title); | 347 EXPECT_EQ(L"set cookie on unload", tab_title); |
347 | 348 |
348 // Navigate to a new cross-site URL that results in an error page. | 349 // Navigate to a new cross-site URL that results in an error page. |
349 // TODO(creis): If this causes crashes or hangs, it might be for the same | 350 // TODO(creis): If this causes crashes or hangs, it might be for the same |
350 // reason as ErrorPageTest::DNSError. See bug 1199491 and | 351 // reason as ErrorPageTest::DNSError. See bug 1199491 and |
351 // http://crbug.com/22877. | 352 // http://crbug.com/22877. |
352 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 353 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
353 tab->NavigateToURLBlockUntilNavigationsComplete( | 354 tab->NavigateToURLBlockUntilNavigationsComplete( |
354 GURL(URLRequestFailedDnsJob::kTestUrl), 2)); | 355 GURL(URLRequestFailedJob::GetMockHttpUrl( |
| 356 net::ERR_NAME_NOT_RESOLVED)), |
| 357 2)); |
355 EXPECT_NE(L"set cookie on unload", GetActiveTabTitle()); | 358 EXPECT_NE(L"set cookie on unload", GetActiveTabTitle()); |
356 | 359 |
357 // Check that the cookie was set, meaning that the onunload handler ran. | 360 // Check that the cookie was set, meaning that the onunload handler ran. |
358 std::string value_result; | 361 std::string value_result; |
359 EXPECT_TRUE(tab->GetCookieByName(url, "onunloadCookie", &value_result)); | 362 EXPECT_TRUE(tab->GetCookieByName(url, "onunloadCookie", &value_result)); |
360 EXPECT_FALSE(value_result.empty()); | 363 EXPECT_FALSE(value_result.empty()); |
361 EXPECT_STREQ("foo", value_result.c_str()); | 364 EXPECT_STREQ("foo", value_result.c_str()); |
362 | 365 |
363 // Check that renderer-initiated navigations still work. In a previous bug, | 366 // Check that renderer-initiated navigations still work. In a previous bug, |
364 // the ResourceDispatcherHost would think that such navigations were | 367 // the ResourceDispatcherHost would think that such navigations were |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 GURL broken_url("chrome://theme"); | 414 GURL broken_url("chrome://theme"); |
412 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); | 415 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(broken_url)); |
413 | 416 |
414 // Make sure the navigation finishes. | 417 // Make sure the navigation finishes. |
415 std::wstring tab_title; | 418 std::wstring tab_title; |
416 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); | 419 EXPECT_TRUE(tab->GetTabTitle(&tab_title)); |
417 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); | 420 EXPECT_EQ(L"chrome://theme/ is not available", tab_title); |
418 } | 421 } |
419 | 422 |
420 } // namespace | 423 } // namespace |
OLD | NEW |