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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/base-uri-self.html

Issue 2699663002: CSP: 'self' should work inside sandboxes. (Closed)
Patch Set: Test + Formatting Created 3 years, 10 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 | « no previous file | third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/base-uri-self.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/base-uri-self.html b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/base-uri-self.html
new file mode 100644
index 0000000000000000000000000000000000000000..e2bbfd3003b54b7d22b0bfc00722ec7daa2885d3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/base-uri-self.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Security-Policy" content="base-uri 'self'">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/security/contentSecurityPolicy/resources/testharness-helper.js"></script>
+</head>
+<body>
+ <script>
+ async_test(t => {
+ assert_equals(document.baseURI, window.location.href);
+
+ var b = document.createElement("base");
+ b.href = "http://127.0.0.1:8000/";
+ document.head.appendChild(b);
+
+ document.addEventListener("securitypolicyviolation", e => t.unreached_func());
+
+ // Wait until the next frame to give the report time to fire
+ requestAnimationFrame(t.step_func_done(_ => {
+ assert_equals(document.baseURI, "http://127.0.0.1:8000/");
+ }));
+ }, "'self' works at top-level.");
+
+ async_test(t => {
+ var i = document.createElement("iframe");
+ i.sandbox = "allow-scripts";
+ i.srcdoc = `
+ <script>
+ document.addEventListener("securitypolicyviolation", e => top.postMessage("FAIL", "*"));
+ </scr` + `ipt>
+ <base href="http://127.0.0.1:8000/">
+ <script>
+ requestAnimationFrame(_ => {
+ top.postMessage(document.baseURI, "*");
+ });
+ </scr` + `ipt>`;
+
+ waitUntilEvent(window, "message")
+ .then(t.step_func_done(e => {
+ assert_equals(e.data, "http://127.0.0.1:8000/");
+ }));
+
+ document.body.appendChild(i);
+ }, "'self' works in a sandbox.");
+ </script>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698