Index: third_party/WebKit/Source/core/frame/csp/CSPSourceTest.cpp |
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPSourceTest.cpp b/third_party/WebKit/Source/core/frame/csp/CSPSourceTest.cpp |
index 39fb4f6075192e30dc235251a1b9dda66756bb43..55dec1396a9008f373b2f71565bc50c73834ae5f 100644 |
--- a/third_party/WebKit/Source/core/frame/csp/CSPSourceTest.cpp |
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSourceTest.cpp |
@@ -53,6 +53,28 @@ TEST_F(CSPSourceTest, BasicMatching) { |
EXPECT_FALSE(source.matches(KURL(base, "HTTP://example.com:8000/FOO/BAR"))); |
} |
+TEST_F(CSPSourceTest, BasicPathMatching) { |
amalika
2016/12/08 19:31:00
Added path matching test
|
+ KURL base; |
+ CSPSource A(csp.get(), "http", "example.com", 8000, "/", |
+ CSPSource::NoWildcard, CSPSource::NoWildcard); |
+ |
+ EXPECT_TRUE(A.matches(KURL(base, "http://example.com:8000"))); |
+ EXPECT_TRUE(A.matches(KURL(base, "http://example.com:8000/"))); |
+ EXPECT_TRUE(A.matches(KURL(base, "http://example.com:8000/foo/bar"))); |
+ |
+ EXPECT_FALSE(A.matches(KURL(base, "http://example.com:8000path"))); |
+ EXPECT_FALSE(A.matches(KURL(base, "http://example.com:9000/"))); |
+ |
+ CSPSource B(csp.get(), "http", "example.com", 8000, "", CSPSource::NoWildcard, |
+ CSPSource::NoWildcard); |
+ EXPECT_TRUE(B.matches(KURL(base, "http://example.com:8000"))); |
+ EXPECT_TRUE(B.matches(KURL(base, "http://example.com:8000/"))); |
+ EXPECT_TRUE(A.matches(KURL(base, "http://example.com:8000/foo/bar"))); |
+ |
+ EXPECT_FALSE(B.matches(KURL(base, "http://example.com:8000path"))); |
+ EXPECT_FALSE(B.matches(KURL(base, "http://example.com:9000/"))); |
+} |
+ |
TEST_F(CSPSourceTest, WildcardMatching) { |
KURL base; |
CSPSource source(csp.get(), "http", "example.com", 0, "/", |
@@ -194,6 +216,9 @@ TEST_F(CSPSourceTest, Subsumes) { |
{{"https", "/page1.html", 0}, {"https", "/page1.html", 0}, true, true}, |
{{"http", "/page1.html", 70}, {"http", "/page1.html", 70}, true, true}, |
{{"https", "/page1.html", 70}, {"https", "/page1.html", 70}, true, true}, |
+ {{"http", "/", 0}, {"http", "", 0}, true, true}, |
+ {{"http", "/", 80}, {"http", "", 80}, true, true}, |
+ {{"http", "/", 80}, {"https", "", 443}, false, true}, |
// One stronger signal in the first CSPSource |
{{"https", "/", 0}, {"http", "/", 0}, true, false}, |
{{"http", "/page1.html", 0}, {"http", "/", 0}, true, false}, |