diff options
Diffstat (limited to 'testing/web-platform/tests/workers/modules/dedicated-worker-options-type.html')
-rw-r--r-- | testing/web-platform/tests/workers/modules/dedicated-worker-options-type.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/workers/modules/dedicated-worker-options-type.html b/testing/web-platform/tests/workers/modules/dedicated-worker-options-type.html new file mode 100644 index 0000000000..bb37a18f2c --- /dev/null +++ b/testing/web-platform/tests/workers/modules/dedicated-worker-options-type.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<title>DedicatedWorker: WorkerOptions 'type'</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + +promise_test(() => { + const worker = new Worker('resources/post-message-on-load-worker.js'); + return new Promise(resolve => worker.onmessage = resolve) + .then(msg_event => assert_equals(msg_event.data, 'LOADED')); +}, 'Test worker construction with the default worker type.'); + +promise_test(() => { + const worker = new Worker('resources/post-message-on-load-worker.js', + { type: 'classic' }); + return new Promise(resolve => worker.onmessage = resolve) + .then(msg_event => assert_equals(msg_event.data, 'LOADED')); +}, 'Test worker construction with the "classic" worker type.'); + +promise_test(() => { + const worker = new Worker('resources/post-message-on-load-worker.js', + { type: 'module' }); + return new Promise(resolve => worker.onmessage = resolve) + .then(msg_event => assert_equals(msg_event.data, 'LOADED')); +}, 'Test worker construction with the "module" worker type.'); + +test(() => { + assert_throws_js( + TypeError, + () => { + new Worker('resources/post-message-on-load-worker.js', { type: '' }); + }, + 'Worker construction with an empty type should throw an exception'); +}, 'Test worker construction with an empty worker type.'); + +test(() => { + assert_throws_js( + TypeError, + () => { + new Worker('resources/post-message-on-load-worker.js', + { type: 'unknown' }); + }, + 'Worker construction with an unknown type should throw an exception'); +}, 'Test worker construction with an unknown worker type.'); + +</script> |