| 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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
| 6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 parameters.pattern_generator_seed, parameters.size, | 2327 parameters.pattern_generator_seed, parameters.size, |
| 2328 download->GetTargetFilePath())); | 2328 download->GetTargetFilePath())); |
| 2329 | 2329 |
| 2330 TestDownloadRequestHandler::CompletedRequests requests; | 2330 TestDownloadRequestHandler::CompletedRequests requests; |
| 2331 request_handler.GetCompletedRequestInfo(&requests); | 2331 request_handler.GetCompletedRequestInfo(&requests); |
| 2332 | 2332 |
| 2333 ASSERT_GE(2u, requests.size()); | 2333 ASSERT_GE(2u, requests.size()); |
| 2334 EXPECT_EQ(document_url.spec(), requests.back()->referrer); | 2334 EXPECT_EQ(document_url.spec(), requests.back()->referrer); |
| 2335 } | 2335 } |
| 2336 | 2336 |
| 2337 // Test that the referrer header is dropped for HTTP downloads from HTTPS. |
| 2338 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ReferrerForHTTPS) { |
| 2339 net::EmbeddedTestServer https_origin( |
| 2340 net::EmbeddedTestServer::Type::TYPE_HTTPS); |
| 2341 net::EmbeddedTestServer http_origin(net::EmbeddedTestServer::Type::TYPE_HTTP); |
| 2342 https_origin.ServeFilesFromDirectory(GetTestFilePath("download", "")); |
| 2343 http_origin.RegisterRequestHandler(CreateBasicResponseHandler( |
| 2344 "/download", base::StringPairs(), "application/octet-stream", "Hello")); |
| 2345 ASSERT_TRUE(https_origin.InitializeAndListen()); |
| 2346 ASSERT_TRUE(http_origin.InitializeAndListen()); |
| 2347 |
| 2348 GURL download_url = http_origin.GetURL("/download"); |
| 2349 GURL referrer_url = https_origin.GetURL( |
| 2350 std::string("/download-link.html?dl=") + download_url.spec()); |
| 2351 |
| 2352 https_origin.StartAcceptingConnections(); |
| 2353 http_origin.StartAcceptingConnections(); |
| 2354 |
| 2355 DownloadItem* download = StartDownloadAndReturnItem(shell(), referrer_url); |
| 2356 WaitForCompletion(download); |
| 2357 |
| 2358 ASSERT_EQ(5, download->GetReceivedBytes()); |
| 2359 EXPECT_EQ("", download->GetReferrerUrl().spec()); |
| 2360 |
| 2361 ASSERT_TRUE(https_origin.ShutdownAndWaitUntilComplete()); |
| 2362 ASSERT_TRUE(http_origin.ShutdownAndWaitUntilComplete()); |
| 2363 } |
| 2364 |
| 2337 // Check that the cookie policy is correctly updated when downloading a file | 2365 // Check that the cookie policy is correctly updated when downloading a file |
| 2338 // that redirects cross origin. | 2366 // that redirects cross origin. |
| 2339 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { | 2367 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { |
| 2340 net::EmbeddedTestServer origin_one; | 2368 net::EmbeddedTestServer origin_one; |
| 2341 net::EmbeddedTestServer origin_two; | 2369 net::EmbeddedTestServer origin_two; |
| 2342 | 2370 |
| 2343 // Block third-party cookies. | 2371 // Block third-party cookies. |
| 2344 ShellNetworkDelegate::SetBlockThirdPartyCookies(true); | 2372 ShellNetworkDelegate::SetBlockThirdPartyCookies(true); |
| 2345 | 2373 |
| 2346 // |url| redirects to a different origin |download| which tries to set a | 2374 // |url| redirects to a different origin |download| which tries to set a |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2738 | 2766 |
| 2739 std::vector<DownloadItem*> downloads; | 2767 std::vector<DownloadItem*> downloads; |
| 2740 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 2768 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 2741 ASSERT_EQ(1u, downloads.size()); | 2769 ASSERT_EQ(1u, downloads.size()); |
| 2742 | 2770 |
| 2743 EXPECT_EQ(FILE_PATH_LITERAL("foo"), | 2771 EXPECT_EQ(FILE_PATH_LITERAL("foo"), |
| 2744 downloads[0]->GetTargetFilePath().BaseName().value()); | 2772 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 2745 } | 2773 } |
| 2746 | 2774 |
| 2747 } // namespace content | 2775 } // namespace content |
| OLD | NEW |