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

Unified Diff: third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp

Issue 2528423002: Part 3.5: Is policy list subsumed under subsuming policy? (Closed)
Patch Set: Removing debugging Created 4 years 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 | « third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp b/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
index 84a605a7de340b2b949491165d584a99d9a4fe78..0e1fcc34adae68fd354a3501fc0c6cacfaf702bb 100644
--- a/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
@@ -438,12 +438,6 @@ TEST_F(SourceListDirectiveTest, Subsumes) {
}
EXPECT_EQ(required.subsumes(returned), test.expected);
-
- // If required is empty, any returned should be subsumed by it.
- SourceListDirective requiredIsEmpty("script-src", "", csp.get());
- EXPECT_TRUE(
- requiredIsEmpty.subsumes(HeapVector<Member<SourceListDirective>>()));
- EXPECT_TRUE(requiredIsEmpty.subsumes(returned));
}
}
@@ -819,4 +813,42 @@ TEST_F(SourceListDirectiveTest, SubsumesUnsafeAttributes) {
}
}
+TEST_F(SourceListDirectiveTest, IsNone) {
+ struct TestCase {
+ String sources;
+ bool expected;
+ } cases[] = {
+ // Source list is 'none'.
+ {"'none'", true},
+ {"", true},
+ {" ", true},
+ // Source list is not 'none'.
+ {"http://example1.com/foo/", false},
+ {"'sha512-321cba'", false},
+ {"'nonce-yay'", false},
+ {"'strict-dynamic'", false},
+ {"'sha512-321cba' http://example1.com/foo/", false},
+ {"http://example1.com/foo/ 'sha512-321cba'", false},
+ {"http://example1.com/foo/ 'nonce-yay'", false},
+ {"'none' 'sha512-321cba' http://example1.com/foo/", false},
+ {"'none' http://example1.com/foo/ 'sha512-321cba'", false},
+ {"'none' http://example1.com/foo/ 'nonce-yay'", false},
+ {"'sha512-321cba' 'nonce-yay'", false},
+ {"http://example1.com/foo/ 'sha512-321cba' 'nonce-yay'", false},
+ {"http://example1.com/foo/ 'sha512-321cba' 'nonce-yay'", false},
+ {" 'sha512-321cba' 'nonce-yay' 'strict-dynamic'", false},
+ };
+
+ for (const auto& test : cases) {
+ SourceListDirective scriptSrc("script-src", test.sources, csp.get());
+ EXPECT_EQ(scriptSrc.isNone(), test.expected);
+
+ SourceListDirective styleSrc("form-action", test.sources, csp.get());
+ EXPECT_EQ(styleSrc.isNone(), test.expected);
+
+ SourceListDirective imgSrc("frame-src", test.sources, csp.get());
+ EXPECT_EQ(styleSrc.isNone(), test.expected);
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698