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

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

Issue 2375423002: Relax '*' in CSPSourceList to match the protected resource's protocol. (Closed)
Patch Set: Created 4 years, 3 months 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/CSPSourceList.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/CSPSourceListTest.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPSourceListTest.cpp b/third_party/WebKit/Source/core/frame/csp/CSPSourceListTest.cpp
index 4860ab0d6eaf3c80375640fef0d112dfb3085ae3..e79be0cb7f443000eff00eebba9bcf9845bf544f 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPSourceListTest.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSourceListTest.cpp
@@ -93,6 +93,32 @@ TEST_F(CSPSourceListTest, BasicMatchingStar)
EXPECT_FALSE(sourceList.matches(KURL(base, "applewebdata://example.test/")));
}
+TEST_F(CSPSourceListTest, StarMatchesSelf)
+{
+ KURL base;
+ String sources = "*";
+ CSPSourceList sourceList(csp.get(), "script-src");
+ parseSourceList(sourceList, sources);
+
+
+ // With a protocol of 'file', '*' matches 'file:':
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::create("file", "", 0);
+ csp->setupSelf(*origin);
+ EXPECT_TRUE(sourceList.matches(KURL(base, "file:///etc/hosts")));
+
+ // The other results are the same as above:
+ EXPECT_TRUE(sourceList.matches(KURL(base, "http://example.com/")));
+ EXPECT_TRUE(sourceList.matches(KURL(base, "https://example.com/")));
+ EXPECT_TRUE(sourceList.matches(KURL(base, "http://example.com/bar")));
+ EXPECT_TRUE(sourceList.matches(KURL(base, "http://foo.example.com/")));
+ EXPECT_TRUE(sourceList.matches(KURL(base, "http://foo.example.com/bar")));
+
+ EXPECT_FALSE(sourceList.matches(KURL(base, "data:https://example.test/")));
+ EXPECT_FALSE(sourceList.matches(KURL(base, "blob:https://example.test/")));
+ EXPECT_FALSE(sourceList.matches(KURL(base, "filesystem:https://example.test/")));
+ EXPECT_FALSE(sourceList.matches(KURL(base, "applewebdata://example.test/")));
+}
+
TEST_F(CSPSourceListTest, BasicMatchingSelf)
{
KURL base;
« no previous file with comments | « third_party/WebKit/Source/core/frame/csp/CSPSourceList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698