summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/content-security-policy/script-src/support/worker-with-script-src-none-set-timeout.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/content-security-policy/script-src/support/worker-with-script-src-none-set-timeout.js')
-rw-r--r--testing/web-platform/tests/content-security-policy/script-src/support/worker-with-script-src-none-set-timeout.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/testing/web-platform/tests/content-security-policy/script-src/support/worker-with-script-src-none-set-timeout.js b/testing/web-platform/tests/content-security-policy/script-src/support/worker-with-script-src-none-set-timeout.js
new file mode 100644
index 0000000000..c4241c97d0
--- /dev/null
+++ b/testing/web-platform/tests/content-security-policy/script-src/support/worker-with-script-src-none-set-timeout.js
@@ -0,0 +1,16 @@
+var id = 0;
+try {
+ id = setTimeout("postMessage('handler invoked')", 100);
+} catch (e) {}
+var message = id === 0 ? "setTimeout blocked" : "setTimeout allowed";
+
+if (typeof SharedWorkerGlobalScope === "function") {
+ onconnect = function (e) {
+ var port = e.ports[0];
+
+ port.onmessage = function () { port.postMessage(message); }
+ port.postMessage(message);
+ };
+} else if (typeof DedicatedWorkerGlobalScope === "function") {
+ self.postMessage(message);
+}