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

Side by Side Diff: content/browser/download/download_browsertest.cc

Issue 2874933002: Don't enforce X-Frame-Options for downloads. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/ancestor_throttle.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/public/test/content_browser_test.h" 48 #include "content/public/test/content_browser_test.h"
49 #include "content/public/test/content_browser_test_utils.h" 49 #include "content/public/test/content_browser_test_utils.h"
50 #include "content/public/test/download_test_observer.h" 50 #include "content/public/test/download_test_observer.h"
51 #include "content/public/test/test_download_request_handler.h" 51 #include "content/public/test/test_download_request_handler.h"
52 #include "content/public/test/test_file_error_injector.h" 52 #include "content/public/test/test_file_error_injector.h"
53 #include "content/public/test/test_utils.h" 53 #include "content/public/test/test_utils.h"
54 #include "content/shell/browser/shell.h" 54 #include "content/shell/browser/shell.h"
55 #include "content/shell/browser/shell_browser_context.h" 55 #include "content/shell/browser/shell_browser_context.h"
56 #include "content/shell/browser/shell_download_manager_delegate.h" 56 #include "content/shell/browser/shell_download_manager_delegate.h"
57 #include "content/shell/browser/shell_network_delegate.h" 57 #include "content/shell/browser/shell_network_delegate.h"
58 #include "content/test/content_browser_test_utils_internal.h"
58 #include "device/power_save_blocker/power_save_blocker.h" 59 #include "device/power_save_blocker/power_save_blocker.h"
59 #include "net/dns/mock_host_resolver.h" 60 #include "net/dns/mock_host_resolver.h"
60 #include "net/test/embedded_test_server/embedded_test_server.h" 61 #include "net/test/embedded_test_server/embedded_test_server.h"
61 #include "net/test/embedded_test_server/http_request.h" 62 #include "net/test/embedded_test_server/http_request.h"
62 #include "net/test/embedded_test_server/http_response.h" 63 #include "net/test/embedded_test_server/http_response.h"
63 #include "net/test/url_request/url_request_mock_http_job.h" 64 #include "net/test/url_request/url_request_mock_http_job.h"
64 #include "net/test/url_request/url_request_slow_download_job.h" 65 #include "net/test/url_request/url_request_slow_download_job.h"
65 #include "ppapi/features/features.h" 66 #include "ppapi/features/features.h"
66 #include "testing/gmock/include/gmock/gmock.h" 67 #include "testing/gmock/include/gmock/gmock.h"
67 #include "testing/gtest/include/gtest/gtest.h" 68 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 2640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 WaitForCompletion(download); 2709 WaitForCompletion(download);
2709 2710
2710 TestDownloadRequestHandler::CompletedRequests completed_requests; 2711 TestDownloadRequestHandler::CompletedRequests completed_requests;
2711 request_handler.GetCompletedRequestInfo(&completed_requests); 2712 request_handler.GetCompletedRequestInfo(&completed_requests);
2712 EXPECT_EQ(kTestRequestCount, static_cast<int>(completed_requests.size())); 2713 EXPECT_EQ(kTestRequestCount, static_cast<int>(completed_requests.size()));
2713 2714
2714 ReadAndVerifyFileContents(parameters.pattern_generator_seed, parameters.size, 2715 ReadAndVerifyFileContents(parameters.pattern_generator_seed, parameters.size,
2715 download->GetTargetFilePath()); 2716 download->GetTargetFilePath());
2716 } 2717 }
2717 2718
2719 // Test to verify that the browser-side enforcement of X-Frame-Options does
2720 // not impact downloads. Since XFO is only checked for subframes, this test
2721 // initiates a download in an iframe and expects it to succeed.
alexmos 2017/05/10 23:41:20 nit: might be nice to reference 717971 here, which
2722 IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadIgnoresXFO) {
2723 GURL main_url(
2724 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(b)"));
2725 GURL download_url(
2726 embedded_test_server()->GetURL("/download/download-with-xfo-deny.html"));
2727 WebContentsImpl* web_contents =
2728 static_cast<WebContentsImpl*>(shell()->web_contents());
2729
2730 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2731
2732 std::unique_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1));
2733 NavigateFrameToURL(web_contents->GetFrameTree()->root()->child_at(0),
2734 download_url);
2735 observer->WaitForFinished();
2736 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2737
2738 std::vector<DownloadItem*> downloads;
2739 DownloadManagerForShell(shell())->GetAllDownloads(&downloads);
2740 ASSERT_EQ(1u, downloads.size());
2741
2742 EXPECT_EQ(FILE_PATH_LITERAL("foo"),
2743 downloads[0]->GetTargetFilePath().BaseName().value());
2744 }
2745
2718 } // namespace content 2746 } // namespace content
OLDNEW
« 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