diff options
Diffstat (limited to 'testing/web-platform/tests/workers/modules/resources/dynamic-import-script-block-cross-origin.js')
-rw-r--r-- | testing/web-platform/tests/workers/modules/resources/dynamic-import-script-block-cross-origin.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/modules/resources/dynamic-import-script-block-cross-origin.js b/testing/web-platform/tests/workers/modules/resources/dynamic-import-script-block-cross-origin.js new file mode 100644 index 0000000000..52ec530663 --- /dev/null +++ b/testing/web-platform/tests/workers/modules/resources/dynamic-import-script-block-cross-origin.js @@ -0,0 +1,24 @@ +const sourcePromise = new Promise(resolve => { + if ('DedicatedWorkerGlobalScope' in self && + self instanceof DedicatedWorkerGlobalScope) { + self.onmessage = e => { + resolve(e.target); + }; + } else if ( + 'SharedWorkerGlobalScope' in self && + self instanceof SharedWorkerGlobalScope) { + self.onconnect = e => { + resolve(e.ports[0]); + }; + } +}); + +const importedModulesPromise = + import('./export-block-cross-origin.js') + .then(module => module.importedModules) + .catch(() => ['ERROR']); + +Promise.all([sourcePromise, importedModulesPromise]).then(results => { + const [source, importedModules] = results; + source.postMessage(importedModules); +}); |