Bug 1461604 [wpt PR 11003] - Worker: Throw an ErrorEvent on a failure of module loading, a=testonly
authorHiroki Nakagawa <nhiroki@chromium.org>
Sat, 19 May 2018 20:23:19 +0000
changeset 419073 4143290a87a68d7268365fe429e48cf6aba9e52d
parent 419072 6ea57382bd997d9c7abe3630e740b86ce64eb45c
child 419074 617ffba267cf5f8f6fa6622a96d48cefb45ec2c5
push id34026
push userapavel@mozilla.com
push dateMon, 21 May 2018 09:47:33 +0000
treeherdermozilla-central@dc1868d255be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1461604, 11003, 843031, 1058998, 558903
milestone62.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
Bug 1461604 [wpt PR 11003] - Worker: Throw an ErrorEvent on a failure 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 <nhiroki@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Cr-Commit-Position: refs/heads/master@{#558903} -- wpt-commits: 92a3d3d14638e8aff86eec3a2b1a6599249ea994 wpt-pr: 11003
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/workers/modules/dedicated-worker-import.html
testing/web-platform/tests/workers/modules/resources/dynamic-import-given-url-worker.js
testing/web-platform/tests/workers/modules/resources/static-import-non-existent-script-worker.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -301939,16 +301939,21 @@
      {}
     ]
    ],
    "workers/modules/resources/static-import-and-then-dynamic-import-worker.js": [
     [
      {}
     ]
    ],
+   "workers/modules/resources/static-import-non-existent-script-worker.js": [
+    [
+     {}
+    ]
+   ],
    "workers/modules/resources/static-import-worker.js": [
     [
      {}
     ]
    ],
    "workers/non-automated/application-cache-dedicated.html": [
     [
      {}
@@ -620708,29 +620713,29 @@
    "6bffa3be83d81e2faa93119e710e4fee93fb855e",
    "testharness"
   ],
   "workers/modules/dedicated-worker-import-meta.html": [
    "32cd3419ff904a2440d9a6eaa7cb28f78d4a7e32",
    "testharness"
   ],
   "workers/modules/dedicated-worker-import.html": [
-   "95973c682b79618cc894417a4f89a758e7e8c7b1",
+   "b9f5a7a0384ac3f34c48f32a378b758880f59b06",
    "testharness"
   ],
   "workers/modules/dedicated-worker-options-type.html": [
    "9f6f1be759beb885e2baa746e36ace83685f649b",
    "testharness"
   ],
   "workers/modules/resources/dynamic-import-and-then-static-import-worker.js": [
    "f4df69196f64cd81e92705186325004ac94db659",
    "support"
   ],
   "workers/modules/resources/dynamic-import-given-url-worker.js": [
-   "372686abd1b2d2d09228a44f6420c646319e0bd1",
+   "0d2cfe16d71bb17577c6cf6cde5973c18c2c70fe",
    "support"
   ],
   "workers/modules/resources/dynamic-import-worker.js": [
    "444e313fe51923097e3672d88d0afd30aac5ecab",
    "support"
   ],
   "workers/modules/resources/empty-worker.js": [
    "84b3339c3419e318803e51f46d7252d9e8ac183b",
@@ -620755,16 +620760,20 @@
   "workers/modules/resources/post-message-on-load-worker.js": [
    "c67a79ade775435a67e5999d17e7cdda450c8e50",
    "support"
   ],
   "workers/modules/resources/static-import-and-then-dynamic-import-worker.js": [
    "f69987442b6a223a868e6c1a7ca6d9cee2976068",
    "support"
   ],
+  "workers/modules/resources/static-import-non-existent-script-worker.js": [
+   "e8e1f0aedcc780aac742af01387dd151b10104bc",
+   "support"
+  ],
   "workers/modules/resources/static-import-worker.js": [
    "6d5fb2c553d2f32cdd16722a85bd65e0a172768c",
    "support"
   ],
   "workers/name-property.html": [
    "1c53fc1fdc2d6c8ed5592d832a18bdbd3bca541b",
    "testharness"
   ],
--- a/testing/web-platform/tests/workers/modules/dedicated-worker-import.html
+++ b/testing/web-platform/tests/workers/modules/dedicated-worker-import.html
@@ -47,9 +47,30 @@ promise_test(() => {
 
 promise_test(() => {
   const scriptURL = 'resources/import-scripts-worker.js';
   const worker = new Worker(scriptURL, { type: 'module' });
   return (new Promise(resolve => worker.onmessage = resolve))
       .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>
--- a/testing/web-platform/tests/workers/modules/resources/dynamic-import-given-url-worker.js
+++ b/testing/web-platform/tests/workers/modules/resources/dynamic-import-given-url-worker.js
@@ -1,4 +1,4 @@
 // Dynamically import the script URL sent by postMessage().
 self.addEventListener('message', e => {
-  import(e.data);
+  import(e.data).catch(error_event => postMessage('ERROR'));
 });
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/workers/modules/resources/static-import-non-existent-script-worker.js
@@ -0,0 +1,1 @@
+import './non-existent-script.js';