Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/workers/resources/script-src-self.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/workers/resources/script-src-self.js b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/workers/resources/script-src-self.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..57f15321a074cfd4a4a0e9ef9cd13f66d6ab2732 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/workers/resources/script-src-self.js |
@@ -0,0 +1,25 @@ |
+importScripts("http://127.0.0.1:8000/resources/testharness.js"); |
+importScripts("http://127.0.0.1:8000/security/contentSecurityPolicy/resources/testharness-helper.js"); |
+ |
+test(t => { |
+ // TODO(mkwst): The error event isn't firing. :/ |
+ |
+ assert_throws(EvalError(), |
+ function () { eval("1 + 1"); }, |
+ "`eval()` should throw 'EvalError'."); |
+ |
+ assert_throws(EvalError(), |
+ function () { var x = new Function("1 + 1"); }, |
+ "`new Function()` should throw 'EvalError'."); |
+}, "`eval()` blocked in " + self.location.protocol); |
+ |
+async_test(t => { |
+ waitUntilCSPEventForEval(t, 21) |
+ .then(_ => t.done()); |
+ |
+ assert_equals( |
+ setTimeout("assert_unreached('setTimeout([string]) should not execute.')", 0), |
+ 0); |
+}, "`setTimeout([string])` blocked in " + self.location.protocol); |
+ |
+done(); |