Skip to content

Commit

Permalink
Bug 1461604 [wpt PR 11003] - Worker: Throw an ErrorEvent on a failure…
Browse files Browse the repository at this point in the history
… of module loading, a=testonly

Automatic update from web-platform-testsWorker: Throw an ErrorEvent on a failure of module loading

This behavior is defined in the HTML spec:

  Step 13: "If the algorithm asynchronously completes with null, queue a task to
  fire an event named error at worker, and return."
  https://html.spec.whatwg.org/multipage/workers.html#worker-processing-model

An ErrorEvent is created on a worker thread, and passed to the main thread to
dispatch it on a worker object in a document context.

Bug: 843031
Change-Id: I1fd82cba1e02b1658bb2b556742f7a206ee754a7
Reviewed-on: https://chromium-review.googlesource.com/1058998
Commit-Queue: Hiroki Nakagawa <nhirokichromium.org>
Reviewed-by: Kouhei Ueno <kouheichromium.org>
Cr-Commit-Position: refs/heads/master{#558903}

--

wpt-commits: 92a3d3d14638e8aff86eec3a2b1a6599249ea994
wpt-pr: 11003

UltraBlame original commit: 4143290a87a68d7268365fe429e48cf6aba9e52d
  • Loading branch information
marco-c committed Oct 3, 2019
1 parent 1e18cbd commit 702be47
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
13 changes: 11 additions & 2 deletions testing/web-platform/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -301944,6 +301944,11 @@
{}
]
],
"workers/modules/resources/static-import-non-existent-script-worker.js": [
[
{}
]
],
"workers/modules/resources/static-import-worker.js": [
[
{}
Expand Down Expand Up @@ -620713,7 +620718,7 @@
"testharness"
],
"workers/modules/dedicated-worker-import.html": [
"95973c682b79618cc894417a4f89a758e7e8c7b1",
"b9f5a7a0384ac3f34c48f32a378b758880f59b06",
"testharness"
],
"workers/modules/dedicated-worker-options-type.html": [
Expand All @@ -620725,7 +620730,7 @@
"support"
],
"workers/modules/resources/dynamic-import-given-url-worker.js": [
"372686abd1b2d2d09228a44f6420c646319e0bd1",
"0d2cfe16d71bb17577c6cf6cde5973c18c2c70fe",
"support"
],
"workers/modules/resources/dynamic-import-worker.js": [
Expand Down Expand Up @@ -620760,6 +620765,10 @@
"f69987442b6a223a868e6c1a7ca6d9cee2976068",
"support"
],
"workers/modules/resources/static-import-non-existent-script-worker.js": [
"e8e1f0aedcc780aac742af01387dd151b10104bc",
"support"
],
"workers/modules/resources/static-import-worker.js": [
"6d5fb2c553d2f32cdd16722a85bd65e0a172768c",
"support"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,25 @@
.then(e => assert_equals(e.data, 'TypeError'));
}, 'importScripts() on module worker should throw an exception.');

promise_test(() => {
const scriptURL = 'resources/non-existent-worker.js';
const worker = new Worker(scriptURL, { type: 'module' });
return new Promise(resolve => worker.onerror = resolve);
}, 'Worker construction for non-existent script should throw an exception.');

promise_test(() => {
const scriptURL = 'resources/static-import-non-existent-script-worker.js';
const worker = new Worker(scriptURL, { type: 'module' });
return new Promise(resolve => worker.onerror = resolve);
}, 'Static import for non-existent script should throw an exception.');

promise_test(() => {
const script_url = './non-existent-worker.js';
const worker = new Worker('resources/dynamic-import-given-url-worker.js',
{ type: 'module' });
worker.postMessage(script_url);
return new Promise(resolve => worker.onmessage = resolve)
.then(msg_event => assert_equals(msg_event.data, 'ERROR'));
}, 'Dynamic import for non-existent script should throw an exception.');

</script>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

self.addEventListener('message', e => {
import(e.data);
import(e.data).catch(error_event => postMessage('ERROR'));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './non-existent-script.js';

0 comments on commit 702be47

Please sign in to comment.