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

Unified Diff: content/browser/frame_host/ancestor_throttle_unittest.cc

Issue 1969743002: XFO: Bypass ancestor checks for 'Content-Disposition: attachment; ...' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « content/browser/frame_host/ancestor_throttle.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/ancestor_throttle_unittest.cc
diff --git a/content/browser/frame_host/ancestor_throttle_unittest.cc b/content/browser/frame_host/ancestor_throttle_unittest.cc
index e0e86676f0fb9e2f6da7bf8cd82189337b51ba1d..ce073ad9a4065fe444c2ad7ee9186bb0e6d195eb 100644
--- a/content/browser/frame_host/ancestor_throttle_unittest.cc
+++ b/content/browser/frame_host/ancestor_throttle_unittest.cc
@@ -20,13 +20,19 @@ namespace {
using HeaderDisposition = AncestorThrottle::HeaderDisposition;
-net::HttpResponseHeaders* GetAncestorHeaders(const char* xfo, const char* csp) {
+net::HttpResponseHeaders* GetAncestorHeaders(const char* xfo,
+ const char* csp,
+ const char* disposition) {
std::string header_string("HTTP/1.1 200 OK\nX-Frame-Options: ");
header_string += xfo;
if (csp != nullptr) {
header_string += "\nContent-Security-Policy: ";
header_string += csp;
}
+ if (disposition != nullptr) {
+ header_string += "\nContent-Disposition: ";
+ header_string += disposition;
+ }
header_string += "\n\n";
std::replace(header_string.begin(), header_string.end(), '\n', '\0');
net::HttpResponseHeaders* headers =
@@ -84,7 +90,7 @@ TEST_F(AncestorThrottleTest, ParsingXFrameOptions) {
for (const auto& test : cases) {
SCOPED_TRACE(test.header);
scoped_refptr<net::HttpResponseHeaders> headers =
- GetAncestorHeaders(test.header, nullptr);
+ GetAncestorHeaders(test.header, nullptr, nullptr);
std::string header_value;
EXPECT_EQ(test.expected,
throttle.ParseHeader(headers.get(), &header_value));
@@ -119,7 +125,7 @@ TEST_F(AncestorThrottleTest, ErrorsParsingXFrameOptions) {
for (const auto& test : cases) {
SCOPED_TRACE(test.header);
scoped_refptr<net::HttpResponseHeaders> headers =
- GetAncestorHeaders(test.header, nullptr);
+ GetAncestorHeaders(test.header, nullptr, nullptr);
std::string header_value;
EXPECT_EQ(test.expected,
throttle.ParseHeader(headers.get(), &header_value));
@@ -172,7 +178,28 @@ TEST_F(AncestorThrottleTest, IgnoreWhenFrameAncestorsPresent) {
for (const auto& test : cases) {
SCOPED_TRACE(test.csp);
scoped_refptr<net::HttpResponseHeaders> headers =
- GetAncestorHeaders("DENY", test.csp);
+ GetAncestorHeaders("DENY", test.csp, nullptr);
+ std::string header_value;
+ EXPECT_EQ(test.expected,
+ throttle.ParseHeader(headers.get(), &header_value));
+ EXPECT_EQ("DENY", header_value);
+ }
+}
+
+TEST_F(AncestorThrottleTest, IgnoreWhenAttachment) {
+ struct TestCase {
+ const char* disposition;
+ AncestorThrottle::HeaderDisposition expected;
+ } cases[] = {{"", HeaderDisposition::DENY},
+ {"attachment", HeaderDisposition::BYPASS},
+ {"inline", HeaderDisposition::DENY},
+ {"invalid", HeaderDisposition::BYPASS}};
+
+ AncestorThrottle throttle(nullptr);
+ for (const auto& test : cases) {
+ SCOPED_TRACE(test.disposition);
+ scoped_refptr<net::HttpResponseHeaders> headers =
+ GetAncestorHeaders("DENY", nullptr, test.disposition);
std::string header_value;
EXPECT_EQ(test.expected,
throttle.ParseHeader(headers.get(), &header_value));
« no previous file with comments | « content/browser/frame_host/ancestor_throttle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698