Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Unified Diff: content/browser/download/download_browsertest.cc

Issue 2927123002: Ensure that the referrer for HTTPS to HTTP downloads is dropped. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_browsertest.cc
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc
index 14298ac99877619a1699fb08a6a27e14756a38dd..be87a30457618b4407eecd2ee471c293cc8fea91 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -2334,6 +2334,34 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, ReferrerForPartialResumption) {
EXPECT_EQ(document_url.spec(), requests.back()->referrer);
}
+// Test that the referrer header is dropped for HTTP downloads from HTTPS.
+IN_PROC_BROWSER_TEST_F(DownloadContentTest, ReferrerForHTTPS) {
+ net::EmbeddedTestServer https_origin(
+ net::EmbeddedTestServer::Type::TYPE_HTTPS);
+ net::EmbeddedTestServer http_origin(net::EmbeddedTestServer::Type::TYPE_HTTP);
+ https_origin.ServeFilesFromDirectory(GetTestFilePath("download", ""));
+ http_origin.RegisterRequestHandler(CreateBasicResponseHandler(
+ "/download", base::StringPairs(), "application/octet-stream", "Hello"));
+ ASSERT_TRUE(https_origin.InitializeAndListen());
+ ASSERT_TRUE(http_origin.InitializeAndListen());
+
+ GURL download_url = http_origin.GetURL("/download");
+ GURL referrer_url = https_origin.GetURL(
+ std::string("/download-link.html?dl=") + download_url.spec());
+
+ https_origin.StartAcceptingConnections();
+ http_origin.StartAcceptingConnections();
+
+ DownloadItem* download = StartDownloadAndReturnItem(shell(), referrer_url);
+ WaitForCompletion(download);
+
+ ASSERT_EQ(5, download->GetReceivedBytes());
+ EXPECT_EQ("", download->GetReferrerUrl().spec());
+
+ ASSERT_TRUE(https_origin.ShutdownAndWaitUntilComplete());
+ ASSERT_TRUE(http_origin.ShutdownAndWaitUntilComplete());
+}
+
// Check that the cookie policy is correctly updated when downloading a file
// that redirects cross origin.
IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) {
« no previous file with comments | « no previous file | content/browser/download/url_downloader.cc » ('j') | content/browser/download/url_downloader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698