author | Eriko Kurimoto <elkurin@chromium.org> |
Tue, 28 Apr 2020 11:37:53 +0000 | |
changeset 527578 | 175fd05289e15654205f9cd95a2ad89c6caa4649 |
parent 527577 | c810496118ef82f0f29650c7deebfda23ab36ea9 |
child 527579 | 99abccb00c35e87ee213a206b75c9bb9558eaa30 |
push id | 37368 |
push user | btara@mozilla.com |
push date | Fri, 01 May 2020 21:45:51 +0000 |
treeherder | mozilla-central@0f9c5a59e45d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | testonly |
bugs | 1630540, 22994, 1071345 |
milestone | 77.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
new file mode 100644 --- /dev/null +++ b/testing/web-platform/tests/workers/dedicated-worker-parse-error-failure.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<title>DedicatedWorker: parse error failure</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> setup({allow_uncaught_exception: true}); </script> +<script src="./support/check-error-arguments.js"></script> +<script> + +promise_test(async () => { + const scriptURL = 'modules/resources/syntax-error.js'; + const worker = new Worker(scriptURL, { type: 'classic' }); + const args = await new Promise(resolve => + worker.onerror = (...args) => resolve(args)); + window.checkErrorArguments(args); +}, 'Classic worker construction for script with syntax error should dispatch ' + + 'an event named error.'); + +promise_test(async () => { + const scriptURL = 'modules/resources/static-import-worker.js'; + const worker = new Worker(scriptURL, { type: 'classic' }); + worker.postMessage('Send message for tests from main script.'); + const args = await new Promise(resolve => + worker.onerror = (...args) => resolve(args)); + window.checkErrorArguments(args); +}, 'Static import on classic worker should dispatch an event named error.'); + +</script>
--- a/testing/web-platform/tests/workers/modules/dedicated-worker-parse-error-failure.html +++ b/testing/web-platform/tests/workers/modules/dedicated-worker-parse-error-failure.html @@ -1,35 +1,51 @@ <!DOCTYPE html> <title>DedicatedWorker: parse error failure</title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script> setup({allow_uncaught_exception: true}); </script> +<script src="../support/check-error-arguments.js"></script> <script> -promise_test(async () => { - const scriptURL = 'resources/syntax-error.js'; - const worker = new Worker(scriptURL, { type: 'classic' }); - return new Promise(resolve => worker.onerror = resolve); -}, 'Classic worker construction for script with syntax error should dispatch ' + - 'an ErrorEvent.'); +// Check if module scripts are supported on dedicated workers. There is no +// direct way to detect it, so we assume it's supported when static import is +// available on the workers. +// +// This check is necessary to appropriately test parse error handling because +// we need to distinguish the parse error invoked by unsupported "import" in +// the top-level script from the parse error invoked by the statically imported +// script which is the one we want to check in this test. +promise_setup(async () => { + const scriptURL = 'resources/static-import-worker.js'; + const worker = new Worker(scriptURL, { type: 'module' }); + worker.postMessage('Send message for tests from main script.'); + const supportsModuleWorkers = await new Promise((resolve, reject) => { + worker.onmessage = e => { + resolve(e.data.length == 1 && e.data[0] == 'export-on-load-script.js'); + }; + worker.onerror = () => resolve(false); + }); + assert_precondition( + supportsModuleWorkers, + "Static import must be supported on module dedicated worker to run this test." + ); +}); promise_test(async () => { const scriptURL = 'resources/syntax-error.js'; const worker = new Worker(scriptURL, { type: 'module' }); - return new Promise(resolve => worker.onerror = resolve); + const args = await new Promise(resolve => + worker.onerror = (...args) => resolve(args)); + window.checkErrorArguments(args); }, 'Module worker construction for script with syntax error should dispatch ' + - 'an ErrorEvent.'); + 'an event named error.'); promise_test(async () => { const scriptURL = 'resources/static-import-syntax-error.js'; const worker = new Worker(scriptURL, { type: 'module' }); - return new Promise(resolve => worker.onerror = resolve); + const args = await new Promise(resolve => + worker.onerror = (...args) => resolve(args)); + window.checkErrorArguments(args); }, 'Static import on module worker for script with syntax error should ' + - 'dispatch an ErrorEvent.'); - -promise_test(() => { - const scriptURL = 'resources/static-import-worker.js'; - const worker = new Worker(scriptURL, { type: 'classic' }); - return new Promise(resolve => worker.onerror = resolve); -}, 'Static import on classic worker should dispatch an ErrorEvent.'); + 'dispatch an event named error.'); </script>