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

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

Issue 2131423003: [Downloads] Add a browser test for <a download> with cross origin iframe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | content/test/data/download/iframe-host.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_browsertest.cc
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc
index ab09c1d06c6c4939c6362ec98d397652731f7681..cbf9ef890a9f584f8a9b4dff8d178693086f66c4 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -575,6 +575,10 @@ class DownloadContentTest : public ContentBrowserTest {
make_scoped_refptr(content::BrowserThread::GetBlockingPool())));
}
+ void SetUpCommandLine(base::CommandLine* commnad_line) override {
+ IsolateAllSitesForTesting(commnad_line);
+ }
+
TestShellDownloadManagerDelegate* GetDownloadManagerDelegate() {
return test_delegate_.get();
}
@@ -2479,4 +2483,43 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, DuplicateContentDisposition) {
downloads[0]->GetTargetFilePath().BaseName().value());
}
+IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadAttributeSameOriginIFrame) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+
+ GURL frame_url = embedded_test_server()->GetURL(
+ "/download/download-attribute.html?target=/download/download-test.lib");
+ GURL document_url = embedded_test_server()->GetURL(
+ "/download/iframe-host.html?target=" + frame_url.spec());
+ DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url);
+ WaitForCompletion(download);
+
+ EXPECT_STREQ(FILE_PATH_LITERAL("suggested-filename"),
+ download->GetTargetFilePath().BaseName().value().c_str());
+}
+
+IN_PROC_BROWSER_TEST_F(DownloadContentTest,
+ DownloadAttributeCrossOriginIFrame) {
+ net::EmbeddedTestServer origin_one;
+ net::EmbeddedTestServer origin_two;
+ ASSERT_TRUE(origin_one.Start());
+ ASSERT_TRUE(origin_two.Start());
+
+ origin_one.ServeFilesFromDirectory(GetTestFilePath("download", ""));
+ origin_two.ServeFilesFromDirectory(GetTestFilePath("download", ""));
+
+ GURL frame_url =
+ origin_one.GetURL("/download-attribute.html?target=" +
+ origin_two.GetURL("/download-test.lib").spec());
+ GURL::Replacements replacements;
+ replacements.SetHostStr("localhost");
+ frame_url = frame_url.ReplaceComponents(replacements);
+ GURL document_url =
+ origin_two.GetURL("/iframe-host.html?target=" + frame_url.spec());
+ DownloadItem* download = StartDownloadAndReturnItem(shell(), document_url);
+ WaitForCompletion(download);
+
+ EXPECT_STREQ(FILE_PATH_LITERAL("download-test.lib"),
+ download->GetTargetFilePath().BaseName().value().c_str());
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/test/data/download/iframe-host.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698