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/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
| 6 #include "base/strings/stringprintf.h" |
6 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/download/download_manager_impl.h" | 8 #include "content/browser/download/download_manager_impl.h" |
8 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
9 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
12 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
15 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
16 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
17 #include "content/shell/shell.h" | 18 #include "content/shell/shell.h" |
| 19 #include "content/shell/shell_content_browser_client.h" |
| 20 #include "content/shell/shell_network_delegate.h" |
18 #include "content/test/content_browser_test.h" | 21 #include "content/test/content_browser_test.h" |
19 #include "content/test/content_browser_test_utils.h" | 22 #include "content/test/content_browser_test_utils.h" |
20 #include "content/test/net/url_request_failed_job.h" | 23 #include "content/test/net/url_request_failed_job.h" |
21 #include "content/test/net/url_request_mock_http_job.h" | 24 #include "content/test/net/url_request_mock_http_job.h" |
22 #include "net/base/net_errors.h" | 25 #include "net/base/net_errors.h" |
23 #include "net/test/embedded_test_server/embedded_test_server.h" | 26 #include "net/test/embedded_test_server/embedded_test_server.h" |
24 #include "net/test/embedded_test_server/http_request.h" | 27 #include "net/test/embedded_test_server/http_request.h" |
25 #include "net/test/embedded_test_server/http_response.h" | 28 #include "net/test/embedded_test_server/http_response.h" |
26 | 29 |
27 namespace content { | 30 namespace content { |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, | 422 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
420 CrossSiteFailedRequest) { | 423 CrossSiteFailedRequest) { |
421 // Visit another URL first to trigger a cross-site navigation. | 424 // Visit another URL first to trigger a cross-site navigation. |
422 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); | 425 NavigateToURL(shell(), GetTestUrl("", "simple_page.html")); |
423 | 426 |
424 // Visit a URL that fails without calling ResourceDispatcherHost::Read. | 427 // Visit a URL that fails without calling ResourceDispatcherHost::Read. |
425 GURL broken_url("chrome://theme"); | 428 GURL broken_url("chrome://theme"); |
426 NavigateToURL(shell(), broken_url); | 429 NavigateToURL(shell(), broken_url); |
427 } | 430 } |
428 | 431 |
| 432 namespace { |
| 433 |
| 434 scoped_ptr<net::test_server::HttpResponse> HandleRedirectRequest( |
| 435 const std::string& request_path, |
| 436 const net::test_server::HttpRequest& request) { |
| 437 if (!StartsWithASCII(request.relative_url, request_path, true)) |
| 438 return scoped_ptr<net::test_server::HttpResponse>(); |
| 439 |
| 440 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 441 new net::test_server::BasicHttpResponse); |
| 442 http_response->set_code(net::HTTP_FOUND); |
| 443 http_response->AddCustomHeader( |
| 444 "Location", request.relative_url.substr(request_path.length())); |
| 445 return http_response.PassAs<net::test_server::HttpResponse>(); |
| 446 } |
| 447 |
| 448 } // namespace |
| 449 |
| 450 // Test that we update the cookie policy URLs correctly when transferring |
| 451 // navigations. |
| 452 IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, CookiePolicy) { |
| 453 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 454 embedded_test_server()->RegisterRequestHandler( |
| 455 base::Bind(&HandleRedirectRequest, "/redirect?")); |
| 456 |
| 457 std::string set_cookie_url(base::StringPrintf( |
| 458 "http://localhost:%d/set_cookie.html", embedded_test_server()->port())); |
| 459 GURL url(embedded_test_server()->GetURL("/redirect?" + set_cookie_url)); |
| 460 |
| 461 ShellContentBrowserClient::SetSwapProcessesForRedirect(true); |
| 462 ShellNetworkDelegate::SetAcceptAllCookies(false); |
| 463 |
| 464 CheckTitleTest(url, "cookie set"); |
| 465 } |
| 466 |
429 } // namespace content | 467 } // namespace content |
OLD | NEW |