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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "content/browser/download/download_manager_impl.h" | 9 #include "content/browser/download/download_manager_impl.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 }; | 96 }; |
97 | 97 |
98 // Test title for content created by javascript window.open(). | 98 // Test title for content created by javascript window.open(). |
99 // See http://crbug.com/5988 | 99 // See http://crbug.com/5988 |
100 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { | 100 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle1) { |
101 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 101 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
102 | 102 |
103 GURL url(embedded_test_server()->GetURL("/dynamic1.html")); | 103 GURL url(embedded_test_server()->GetURL("/dynamic1.html")); |
104 base::string16 title; | 104 base::string16 title; |
105 ASSERT_TRUE(GetPopupTitle(url, &title)); | 105 ASSERT_TRUE(GetPopupTitle(url, &title)); |
106 EXPECT_TRUE(base::StartsWith(title, ASCIIToUTF16("My Popup Title"), true)) | 106 EXPECT_TRUE(base::StartsWith(title, ASCIIToUTF16("My Popup Title"), |
| 107 base::CompareCase::SENSITIVE)) |
107 << "Actual title: " << title; | 108 << "Actual title: " << title; |
108 } | 109 } |
109 | 110 |
110 // Test title for content created by javascript window.open(). | 111 // Test title for content created by javascript window.open(). |
111 // See http://crbug.com/5988 | 112 // See http://crbug.com/5988 |
112 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { | 113 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, DynamicTitle2) { |
113 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 114 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
114 | 115 |
115 GURL url(embedded_test_server()->GetURL("/dynamic2.html")); | 116 GURL url(embedded_test_server()->GetURL("/dynamic2.html")); |
116 base::string16 title; | 117 base::string16 title; |
117 ASSERT_TRUE(GetPopupTitle(url, &title)); | 118 ASSERT_TRUE(GetPopupTitle(url, &title)); |
118 EXPECT_TRUE(base::StartsWith(title, ASCIIToUTF16("My Dynamic Title"), true)) | 119 EXPECT_TRUE(base::StartsWith(title, ASCIIToUTF16("My Dynamic Title"), |
| 120 base::CompareCase::SENSITIVE)) |
119 << "Actual title: " << title; | 121 << "Actual title: " << title; |
120 } | 122 } |
121 | 123 |
122 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 124 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
123 SniffHTMLWithNoContentType) { | 125 SniffHTMLWithNoContentType) { |
124 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), | 126 CheckTitleTest(GetMockURL("content-sniffer-test0.html"), |
125 "Content Sniffer Test 0"); | 127 "Content Sniffer Test 0"); |
126 } | 128 } |
127 | 129 |
128 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 130 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 // Check that the cookie was set. | 261 // Check that the cookie was set. |
260 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); | 262 EXPECT_EQ("onunloadCookie=foo", GetCookies(url)); |
261 } | 263 } |
262 | 264 |
263 namespace { | 265 namespace { |
264 | 266 |
265 // Handles |request| by serving a redirect response. | 267 // Handles |request| by serving a redirect response. |
266 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler( | 268 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler( |
267 const std::string& path, | 269 const std::string& path, |
268 const net::test_server::HttpRequest& request) { | 270 const net::test_server::HttpRequest& request) { |
269 if (!base::StartsWithASCII(path, request.relative_url, true)) | 271 if (!base::StartsWith(path, request.relative_url, |
| 272 base::CompareCase::SENSITIVE)) |
270 return scoped_ptr<net::test_server::HttpResponse>(); | 273 return scoped_ptr<net::test_server::HttpResponse>(); |
271 | 274 |
272 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 275 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
273 new net::test_server::BasicHttpResponse); | 276 new net::test_server::BasicHttpResponse); |
274 http_response->set_code(net::HTTP_NO_CONTENT); | 277 http_response->set_code(net::HTTP_NO_CONTENT); |
275 return http_response.Pass(); | 278 return http_response.Pass(); |
276 } | 279 } |
277 | 280 |
278 } // namespace | 281 } // namespace |
279 | 282 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 439 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
437 GURL broken_url("chrome://theme"); | 440 GURL broken_url("chrome://theme"); |
438 NavigateToURL(shell(), broken_url); | 441 NavigateToURL(shell(), broken_url); |
439 } | 442 } |
440 | 443 |
441 namespace { | 444 namespace { |
442 | 445 |
443 scoped_ptr<net::test_server::HttpResponse> HandleRedirectRequest( | 446 scoped_ptr<net::test_server::HttpResponse> HandleRedirectRequest( |
444 const std::string& request_path, | 447 const std::string& request_path, |
445 const net::test_server::HttpRequest& request) { | 448 const net::test_server::HttpRequest& request) { |
446 if (!base::StartsWithASCII(request.relative_url, request_path, true)) | 449 if (!base::StartsWith(request.relative_url, request_path, |
| 450 base::CompareCase::SENSITIVE)) |
447 return scoped_ptr<net::test_server::HttpResponse>(); | 451 return scoped_ptr<net::test_server::HttpResponse>(); |
448 | 452 |
449 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 453 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
450 new net::test_server::BasicHttpResponse); | 454 new net::test_server::BasicHttpResponse); |
451 http_response->set_code(net::HTTP_FOUND); | 455 http_response->set_code(net::HTTP_FOUND); |
452 http_response->AddCustomHeader( | 456 http_response->AddCustomHeader( |
453 "Location", request.relative_url.substr(request_path.length())); | 457 "Location", request.relative_url.substr(request_path.length())); |
454 return http_response.Pass(); | 458 return http_response.Pass(); |
455 } | 459 } |
456 | 460 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 NavigateToURLBlockUntilNavigationsComplete( | 516 NavigateToURLBlockUntilNavigationsComplete( |
513 shell(), | 517 shell(), |
514 embedded_test_server()->GetURL("/client_redirect.html"), | 518 embedded_test_server()->GetURL("/client_redirect.html"), |
515 2); | 519 2); |
516 | 520 |
517 EXPECT_TRUE( | 521 EXPECT_TRUE( |
518 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 522 delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
519 } | 523 } |
520 | 524 |
521 } // namespace content | 525 } // namespace content |
OLD | NEW |