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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Handles |request| by serving a redirect response. | 264 // Handles |request| by serving a redirect response. |
265 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler( | 265 scoped_ptr<net::test_server::HttpResponse> NoContentResponseHandler( |
266 const std::string& path, | 266 const std::string& path, |
267 const net::test_server::HttpRequest& request) { | 267 const net::test_server::HttpRequest& request) { |
268 if (!StartsWithASCII(path, request.relative_url, true)) | 268 if (!StartsWithASCII(path, request.relative_url, true)) |
269 return scoped_ptr<net::test_server::HttpResponse>(); | 269 return scoped_ptr<net::test_server::HttpResponse>(); |
270 | 270 |
271 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 271 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
272 new net::test_server::BasicHttpResponse); | 272 new net::test_server::BasicHttpResponse); |
273 http_response->set_code(net::HTTP_NO_CONTENT); | 273 http_response->set_code(net::HTTP_NO_CONTENT); |
274 return http_response.PassAs<net::test_server::HttpResponse>(); | 274 return http_response.Pass(); |
275 } | 275 } |
276 | 276 |
277 } // namespace | 277 } // namespace |
278 | 278 |
279 // Tests that the unload handler is not run for 204 responses. | 279 // Tests that the unload handler is not run for 204 responses. |
280 // If this flakes use http://crbug.com/80596. | 280 // If this flakes use http://crbug.com/80596. |
281 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 281 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
282 CrossSiteNoUnloadOn204) { | 282 CrossSiteNoUnloadOn204) { |
283 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 283 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
284 | 284 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 const std::string& request_path, | 443 const std::string& request_path, |
444 const net::test_server::HttpRequest& request) { | 444 const net::test_server::HttpRequest& request) { |
445 if (!StartsWithASCII(request.relative_url, request_path, true)) | 445 if (!StartsWithASCII(request.relative_url, request_path, true)) |
446 return scoped_ptr<net::test_server::HttpResponse>(); | 446 return scoped_ptr<net::test_server::HttpResponse>(); |
447 | 447 |
448 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 448 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
449 new net::test_server::BasicHttpResponse); | 449 new net::test_server::BasicHttpResponse); |
450 http_response->set_code(net::HTTP_FOUND); | 450 http_response->set_code(net::HTTP_FOUND); |
451 http_response->AddCustomHeader( | 451 http_response->AddCustomHeader( |
452 "Location", request.relative_url.substr(request_path.length())); | 452 "Location", request.relative_url.substr(request_path.length())); |
453 return http_response.PassAs<net::test_server::HttpResponse>(); | 453 return http_response.Pass(); |
454 } | 454 } |
455 | 455 |
456 } // namespace | 456 } // namespace |
457 | 457 |
458 // Test that we update the cookie policy URLs correctly when transferring | 458 // Test that we update the cookie policy URLs correctly when transferring |
459 // navigations. | 459 // navigations. |
460 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, CookiePolicy) { | 460 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, CookiePolicy) { |
461 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 461 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
462 embedded_test_server()->RegisterRequestHandler( | 462 embedded_test_server()->RegisterRequestHandler( |
463 base::Bind(&HandleRedirectRequest, "/redirect?")); | 463 base::Bind(&HandleRedirectRequest, "/redirect?")); |
464 | 464 |
465 std::string set_cookie_url(base::StringPrintf( | 465 std::string set_cookie_url(base::StringPrintf( |
466 "http://localhost:%d/set_cookie.html", embedded_test_server()->port())); | 466 "http://localhost:%d/set_cookie.html", embedded_test_server()->port())); |
467 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url)); | 467 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url)); |
468 | 468 |
469 ShellContentBrowserClient::SetSwapProcessesForRedirect(true); | 469 ShellContentBrowserClient::SetSwapProcessesForRedirect(true); |
470 ShellNetworkDelegate::SetAcceptAllCookies(false); | 470 ShellNetworkDelegate::SetAcceptAllCookies(false); |
471 | 471 |
472 CheckTitleTest(url, "cookie set"); | 472 CheckTitleTest(url, "cookie set"); |
473 } | 473 } |
474 | 474 |
475 } // namespace content | 475 } // namespace content |
OLD | NEW |