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

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

Issue 2487983003: Part 2.3: Is policy list subsumed under subsuming policy? (Closed)
Patch Set: Properly handling scheme-source to scheme-source matching Created 4 years, 1 month 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
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 c9f16700d83011311de3b31c057881a96761cb0b..c587a8bca0810a8bd7b03d7f5a9e1d064b9561bb 100644
--- a/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
@@ -253,8 +253,8 @@ TEST_F(SourceListDirectiveTest, GetIntersectCSPSources) {
{"http://*.example1.com/foo/ http://foo.example2.com/bar/",
"http://example1.com/foo/ http://foo.example2.com/bar/"},
// Normalizing ports.
- {"http://example1.com:80/foo/ http://example2.com/bar/",
- "http://example1.com:80/foo/ http://example2.com/bar/"},
+ {"http://example1.com/foo/ http://example2.com/bar/",
+ "http://example1.com/foo/ http://example2.com/bar/"},
{"http://example1.com/foo/ http://example2.com:90/bar/",
"http://example1.com/foo/"},
{"http://example1.com:*/foo/ http://example2.com/bar/",
@@ -293,4 +293,57 @@ TEST_F(SourceListDirectiveTest, GetIntersectCSPSources) {
}
}
+TEST_F(SourceListDirectiveTest, GetIntersectCSPSourcesSchemes) {
+ KURL base;
+ String sources =
+ "http: http://example1.com/foo/ https://example1.com/foo/ "
+ "http://example1.com/bar/page.html";
+ SourceListDirective sourceList("script-src", sources, csp.get());
Mike West 2016/11/17 10:58:31 Might as well just inline the source string here.
+ struct TestCase {
+ String sources;
+ String expected;
+ } cases[] = {
+ {"http:",
+ "http: http://example1.com/foo/ https://example1.com/foo/ "
+ "http://example1.com/bar/page.html"},
+ {"https:",
+ "https: https://example1.com/foo/ https://example1.com/foo/ "
+ "https://example1.com/bar/page.html"},
+ {"https: http://example1.com/foo/",
+ "https: http://example1.com/foo/ https://example1.com/foo/ "
+ "https://example1.com/bar/page.html"},
+ {"http://*.example1.com/",
+ "http://*.example1.com/ http://example1.com/foo/ "
+ "https://example1.com/foo/ http://example1.com/bar/page.html"},
+ {"http://example1.com/foo/ https://example1.com/foo/",
+ "https://example1.com/foo/ http://example1.com/foo/ "
+ "https://example1.com/foo/"},
+ {"https://example1.com/foo/ https://example1.com/foo/",
+ "https://example1.com/foo/ https://example1.com/foo/ "
+ "https://example1.com/foo/"},
+ {"https://example1.com/foo/ http://example1.com/foo/",
+ "http://example1.com/foo/ http://example1.com/foo/ "
+ "https://example1.com/foo/"},
+ };
+
+ for (const auto& test : cases) {
+ SourceListDirective secondList("script-src", test.sources, csp.get());
+ HeapVector<Member<CSPSource>> normalized =
+ sourceList.getIntersectCSPSources(secondList.m_list);
Mike West 2016/11/17 10:58:31 This should be symmetric right? Could you add chec
+ SourceListDirective helperSourceList("script-src", test.expected,
+ csp.get());
+ HeapVector<Member<CSPSource>> expected = helperSourceList.m_list;
+ EXPECT_EQ(normalized.size(), expected.size());
+ for (size_t i = 0; i < normalized.size(); i++) {
+ Source a = {normalized[i]->m_scheme, normalized[i]->m_host,
+ normalized[i]->m_port, normalized[i]->m_path,
+ normalized[i]->m_hostWildcard, normalized[i]->m_portWildcard};
+ Source b = {expected[i]->m_scheme, expected[i]->m_host,
+ expected[i]->m_port, expected[i]->m_path,
+ expected[i]->m_hostWildcard, expected[i]->m_portWildcard};
+ EXPECT_TRUE(equalSources(a, b));
+ }
+ }
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698