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/workers/modules/dedicated-worker-import-data-url.any.js | |
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/workers/modules/dedicated-worker-import-data-url.any.js')
-rw-r--r-- | testing/web-platform/tests/workers/modules/dedicated-worker-import-data-url.any.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/modules/dedicated-worker-import-data-url.any.js b/testing/web-platform/tests/workers/modules/dedicated-worker-import-data-url.any.js new file mode 100644 index 0000000000..b837ad67da --- /dev/null +++ b/testing/web-platform/tests/workers/modules/dedicated-worker-import-data-url.any.js @@ -0,0 +1,25 @@ +// META: script=/workers/modules/resources/import-test-cases.js + +// Imports |testCase.scriptURL| on a dedicated worker loaded from a data URL, +// and waits until the list of imported modules is sent from the worker. Passes +// if the list is equal to |testCase.expectation|. +function import_data_url_test(testCase) { + promise_test(async () => { + // The Access-Control-Allow-Origin header is necessary because a worker + // loaded from a data URL has a null origin and import() on the worker + // without the header is blocked. + const importURL = new URL(testCase.scriptURL, location.href) + + '?pipe=header(Access-Control-Allow-Origin, *)'; + const dataURL = `data:text/javascript,import "${importURL}";`; + + const worker = new Worker(dataURL, { type: 'module'}); + worker.postMessage('Send message for tests from main script.'); + const msgEvent = await new Promise((resolve, reject) =>{ + worker.onmessage = resolve; + worker.onerror = reject; + }).catch(e => assert_true(false)); + assert_array_equals(msgEvent.data, testCase.expectation); + }, testCase.description); +} + +testCases.forEach(import_data_url_test); |