| 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));
|
|
|