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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/script-src-self.sub.js

Issue 2765443003: CSP: Upstream worker tests to WPT repository. (Closed)
Patch Set: 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
Index: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/script-src-self.sub.js
diff --git a/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/script-src-self.sub.js b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/script-src-self.sub.js
new file mode 100644
index 0000000000000000000000000000000000000000..43ed2d40e0bbefa91b5b8541ed8dce53ad914af7
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/content-security-policy/inside-worker/support/script-src-self.sub.js
@@ -0,0 +1,31 @@
+importScripts("{{location[server]}}/resources/testharness.js");
+importScripts("{{location[server]}}/content-security-policy/support/testharness-helper.js");
+
+test(t => {
+ assert_throws("NetworkError",
+ _ => importScripts("http://{{domains[www]}}:{{ports[http][1]}}/content-security-policy/support/fail.js"),
+ "importScripts should throw `NetworkError`");
+}, "Cross-origin `importScripts()` blocked in " + self.location.protocol + self.location.search);
+
+test(t => {
+ // TODO(mkwst): The error event isn't firing. :/
+
+ assert_throws(EvalError(),
+ _ => eval("1 + 1"),
+ "`eval()` should throw 'EvalError'.");
+
+ assert_throws(EvalError(),
+ _ => new Function("1 + 1"),
+ "`new Function()` should throw 'EvalError'.");
+}, "`eval()` blocked in " + self.location.protocol + self.location.search);
+
+async_test(t => {
+ waitUntilCSPEventForEval(t, 27)
+ .then(_ => t.done());
+
+ assert_equals(
+ setTimeout("assert_unreached('setTimeout([string]) should not execute.')", 0),
+ 0);
+}, "`setTimeout([string])` blocked in " + self.location.protocol + self.location.search);
+
+done();

Powered by Google App Engine
This is Rietveld 408576698