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

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

Issue 2714203002: Moved all tests about bypassing CSP into ContentSecurityPolicyTest (Closed)
Patch Set: Fixed build errors. Rebase-update. Created 3 years, 9 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/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 643f57dd3fbf61a9f398ecd2aa1ea709691d3d65..39f88cf8c75e757f3af54cbdbc5ce7095dd6f315 100644
--- a/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp
@@ -9,7 +9,6 @@
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "platform/network/ResourceRequest.h"
#include "platform/weborigin/KURL.h"
-#include "platform/weborigin/SchemeRegistry.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -134,100 +133,6 @@ TEST_F(SourceListDirectiveTest, BasicMatchingSelf) {
EXPECT_TRUE(sourceList.allows(KURL(base, "https://example.test/")));
}
-TEST_F(SourceListDirectiveTest, BlobMatchingSelf) {
- KURL base;
- String sources = "'self'";
- SourceListDirective sourceList("script-src", sources, csp.get());
-
- EXPECT_TRUE(sourceList.allows(KURL(base, "https://example.test/")));
- EXPECT_FALSE(sourceList.allows(KURL(base, "blob:https://example.test/")));
-
- // Register "https" as bypassing CSP, which should trigger the innerURL
- // behavior.
- SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy("https");
-
- EXPECT_TRUE(sourceList.allows(KURL(base, "https://example.test/")));
- EXPECT_TRUE(sourceList.allows(KURL(base, "blob:https://example.test/")));
-
- // Unregister the scheme to clean up after ourselves.
- SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(
- "https");
-}
-
-TEST_F(SourceListDirectiveTest, FilesystemMatchingSelf) {
- KURL base;
- String sources = "'self'";
- SourceListDirective sourceList("script-src", sources, csp.get());
-
- EXPECT_TRUE(sourceList.allows(KURL(base, "https://example.test/")));
- EXPECT_FALSE(sourceList.allows(
- KURL(base, "filesystem:https://example.test/file.txt")));
-
- // Register "https" as bypassing CSP, which should trigger the innerURL
- // behavior.
- SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy("https");
-
- EXPECT_TRUE(sourceList.allows(KURL(base, "https://example.test/")));
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "filesystem:https://example.test/file.txt")));
-
- // Unregister the scheme to clean up after ourselves.
- SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(
- "https");
-}
-
-TEST_F(SourceListDirectiveTest, BlobDisallowedWhenBypassingSelfScheme) {
- KURL base;
- String sources = "'self' blob:";
- SourceListDirective sourceList("script-src", sources, csp.get());
-
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "blob:https://example.test/1be95204-93d6-4GUID")));
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "blob:https://not-example.test/1be95204-93d6-4GUID")));
-
- // Register "https" as bypassing CSP, which should trigger the innerURL
- // behavior.
- SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy("https");
-
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "blob:https://example.test/1be95204-93d6-4GUID")));
- // TODO(mkwst, arthursonzogni): This should be true.
- // See http://crbug.com/692046
- EXPECT_FALSE(sourceList.allows(
- KURL(base, "blob:https://not-example.test/1be95204-93d6-4GUID")));
-
- // Unregister the scheme to clean up after ourselves.
- SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(
- "https");
-}
-
-TEST_F(SourceListDirectiveTest, FilesystemDisallowedWhenBypassingSelfScheme) {
- KURL base;
- String sources = "'self' filesystem:";
- SourceListDirective sourceList("script-src", sources, csp.get());
-
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "filesystem:https://example.test/file.txt")));
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "filesystem:https://not-example.test/file.txt")));
-
- // Register "https" as bypassing CSP, which should trigger the innerURL
- // behavior.
- SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy("https");
-
- EXPECT_TRUE(sourceList.allows(
- KURL(base, "filesystem:https://example.test/file.txt")));
- // TODO(mkwst, arthursonzogni): This should be true.
- // See http://crbug.com/692046
- EXPECT_FALSE(sourceList.allows(
- KURL(base, "filesystem:https://not-example.test/file.txt")));
-
- // Unregister the scheme to clean up after ourselves.
- SchemeRegistry::removeURLSchemeRegisteredAsBypassingContentSecurityPolicy(
- "https");
-}
-
TEST_F(SourceListDirectiveTest, BlobMatchingBlob) {
KURL base;
String sources = "blob:";
« 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