diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html')
-rw-r--r-- | testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html new file mode 100644 index 0000000000..0bfc503d06 --- /dev/null +++ b/testing/web-platform/tests/workers/constructors/SharedWorker/same-origin.html @@ -0,0 +1,62 @@ +<!doctype html> +<title>same-origin checks</title> +<meta name="timeout" content="long"> +<link rel=help href="https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworker"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +// Needed to prevent a race condition if a worker throws an exception that may or may +// not propogate to the window before the tests finish +setup({allow_uncaught_exception: true}); + +testSharedWorkerHelper = (t, script) => { + try { + const worker = new SharedWorker(script, ''); + worker.onerror = t.step_func_done(e => { + assert_true(e instanceof Event); + }); + } catch (e) { + assert_throws_dom("SecurityError", () => {throw e}, "DOMExceptions thrown on cross-origin SharedWorker construction must be SecurityErrors"); + t.done(); + } +} + +test(() => { + assert_throws_dom("SecurityError", () => { new SharedWorker('unsupported:', ''); }); +}, "unsupported_scheme"); + +async_test(t => { + const worker = new SharedWorker('data:,onconnect = e => { e.ports[0].postMessage(1); }', ''); + worker.port.onmessage = t.step_func_done(e => { + assert_equals(e.data, 1); + }); +}, "data_url"); + +async_test(t => { + testSharedWorkerHelper(t, 'javascript:""'); +}, "javascript_url"); + +async_test(t => { + testSharedWorkerHelper(t, 'about:blank'); +}, "about_blank"); + +async_test(t => { + testSharedWorkerHelper(t, 'http://www.opera.com/'); +}, "opera_com"); + +async_test(t => { + testSharedWorkerHelper(t, location.protocol+'//'+location.hostname+':81/'); +}, "port_81"); + +async_test(t => { + testSharedWorkerHelper(t, 'https://'+location.hostname+':80/'); +}, "https_port_80"); + +async_test(t => { + testSharedWorkerHelper(t, 'https://'+location.hostname+':8000/'); +}, "https_port_8000"); + +async_test(t => { + testSharedWorkerHelper(t, 'http://'+location.hostname+':8012/'); +}, "http_port_8012"); +</script> |