Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicyTest.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicyTest.cpp b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicyTest.cpp |
| index b254f6f8bcd065522f161accce155a72182e4b6b..4ae81da025369984eeeda12c619330aaf1e9bf57 100644 |
| --- a/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicyTest.cpp |
| +++ b/third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicyTest.cpp |
| @@ -911,4 +911,35 @@ TEST_F(ContentSecurityPolicyTest, ShouldEnforceEmbeddersPolicy) { |
| } |
| } |
| +TEST_F(ContentSecurityPolicyTest, Subsumes) { |
|
amalika
2016/11/28 11:56:22
Since we test subsumption on other levels + layout
|
| + ContentSecurityPolicy* other = ContentSecurityPolicy::create(); |
| + EXPECT_TRUE(csp->subsumes(*other)); |
| + EXPECT_TRUE(other->subsumes(*csp)); |
| + |
| + csp->didReceiveHeader("default-src http://example.com;", |
| + ContentSecurityPolicyHeaderTypeEnforce, |
| + ContentSecurityPolicyHeaderSourceHTTP); |
| + // If this CSP is not empty, the other must not be empty either. |
| + EXPECT_FALSE(csp->subsumes(*other)); |
| + EXPECT_TRUE(other->subsumes(*csp)); |
| + |
| + // Report-only policies do not impact subsumption. |
| + other->didReceiveHeader("default-src http://example.com;", |
| + ContentSecurityPolicyHeaderTypeReport, |
| + ContentSecurityPolicyHeaderSourceHTTP); |
| + EXPECT_FALSE(csp->subsumes(*other)); |
| + |
| + // CSPDirectiveLists have to subsume. |
| + other->didReceiveHeader("default-src http://example.com https://another.com;", |
| + ContentSecurityPolicyHeaderTypeEnforce, |
| + ContentSecurityPolicyHeaderSourceHTTP); |
| + EXPECT_FALSE(csp->subsumes(*other)); |
| + |
| + // `other` is stricter than `this`. |
| + other->didReceiveHeader("default-src https://example.com;", |
| + ContentSecurityPolicyHeaderTypeEnforce, |
| + ContentSecurityPolicyHeaderSourceHTTP); |
| + EXPECT_TRUE(csp->subsumes(*other)); |
| +} |
| + |
| } // namespace blink |