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

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

Issue 2874933002: Don't enforce X-Frame-Options for downloads. (Closed)
Patch Set: Add a reference to 717971 Created 3 years, 7 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/browser/frame_host/ancestor_throttle.cc » ('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 67bc08dbdd14a1034c74ede02fb0e1898119fee2..14298ac99877619a1699fb08a6a27e14756a38dd 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -55,6 +55,7 @@
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_download_manager_delegate.h"
#include "content/shell/browser/shell_network_delegate.h"
+#include "content/test/content_browser_test_utils_internal.h"
#include "device/power_save_blocker/power_save_blocker.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
@@ -2715,4 +2716,32 @@ IN_PROC_BROWSER_TEST_F(ParallelDownloadTest, ParallelDownloadComplete) {
download->GetTargetFilePath());
}
+// Test to verify that the browser-side enforcement of X-Frame-Options does
+// not impact downloads. Since XFO is only checked for subframes, this test
+// initiates a download in an iframe and expects it to succeed.
+// See https://crbug.com/717971.
+IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadIgnoresXFO) {
+ GURL main_url(
+ embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(b)"));
+ GURL download_url(
+ embedded_test_server()->GetURL("/download/download-with-xfo-deny.html"));
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ std::unique_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1));
+ NavigateFrameToURL(web_contents->GetFrameTree()->root()->child_at(0),
+ download_url);
+ observer->WaitForFinished();
+ EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE));
+
+ std::vector<DownloadItem*> downloads;
+ DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
+ ASSERT_EQ(1u, downloads.size());
+
+ EXPECT_EQ(FILE_PATH_LITERAL("foo"),
+ downloads[0]->GetTargetFilePath().BaseName().value());
+}
+
} // namespace content
« no previous file with comments | « no previous file | content/browser/frame_host/ancestor_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698