diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/json-module-service-worker-test.https.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/json-module-service-worker-test.https.html')
-rw-r--r-- | testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/json-module-service-worker-test.https.html | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/json-module-service-worker-test.https.html b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/json-module-service-worker-test.https.html new file mode 100644 index 0000000000..cc47da1499 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/json-module-assertions/json-module-service-worker-test.https.html @@ -0,0 +1,29 @@ +<!doctype html> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> + promise_test(async (test) => { + const reg = await navigator.serviceWorker.register('./serviceworker.js', { type: 'module' }); + test.add_cleanup(() => reg.unregister()); + assert_not_equals(reg.installing, undefined); + }, "Javascript importing JSON Module should load within the context of a service worker"); + + promise_test(test => { + return promise_rejects_dom(test, "SecurityError", + navigator.serviceWorker.register('./module.json', { type: 'module' }), + "Attempting to load JSON as a service worker should fail"); + }, "Trying to register a service worker with a top-level JSON Module should fail"); + + promise_test(async (test) => { + const reg = await navigator.serviceWorker.register('./serviceworker-dynamic-import.js', { type: 'module' }); + test.add_cleanup(() => reg.unregister()); + assert_not_equals(reg.installing, undefined); + reg.installing.postMessage("PING"); + const msgEvent = await new Promise(resolve => { + navigator.serviceWorker.onmessage = resolve; + }); + assert_equals(msgEvent.data, "FAILED"); + }, "JSON Module dynamic import should not load within the context of a service worker"); +</script>
\ No newline at end of file |