Bug 1447901 [wpt PR 10139] - Worker: Allow dynamic import() on DedicatedWorkerGlobalScope, a=testonly
authorHiroki Nakagawa <nhiroki@chromium.org>
Mon, 09 Apr 2018 18:10:14 +0000
changeset 467179 37d525724639f11ca2ba1e37fc3fc07594455282
parent 467178 da41b05b899f09b9db9c9515be5af1960f177a9b
child 467180 c314a1640514d9853a7832d9ba11134c606e0570
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1447901, 10139, 680046, 970127, 545748
milestone61.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 1447901 [wpt PR 10139] - Worker: Allow dynamic import() on DedicatedWorkerGlobalScope, a=testonly Automatic update from web-platform-testsWorker: Allow dynamic import() on DedicatedWorkerGlobalScope This CL allows dynamic import() on DedicatedWorkerGlobalScope and adds WPT tests. Note that ES Modules on DedicatedWorker is an experimental feature behind the runtime flag. Design doc: https://docs.google.com/document/d/1IMGWAK7Wq37mLehwkbysNRBBnhQBo3z2MbYyMkViEnY/edit#heading=h.637avx8i5qtn Bug: 680046 Change-Id: I1f8fed5c319aab634f96bcfabeb3c95f5dc7d9a7 Reviewed-on: https://chromium-review.googlesource.com/970127 Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org> Reviewed-by: Kouhei Ueno <kouhei@chromium.org> Reviewed-by: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Makoto Shimazu <shimazu@chromium.org> Cr-Commit-Position: refs/heads/master@{#545748} wpt-commits: e31f590e67dfb68f1c532ba62c79c50c485f62ed wpt-pr: 10139 wpt-commits: e31f590e67dfb68f1c532ba62c79c50c485f62ed wpt-pr: 10139
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/workers/modules/dedicated-worker-import.html
testing/web-platform/tests/workers/modules/dedicated-worker-static-import.html
testing/web-platform/tests/workers/modules/resources/dynamic-import-and-then-static-import-worker.js
testing/web-platform/tests/workers/modules/resources/dynamic-import-worker.js
testing/web-platform/tests/workers/modules/resources/nested-dynamic-import-worker.js
testing/web-platform/tests/workers/modules/resources/nested-static-import-worker.js
testing/web-platform/tests/workers/modules/resources/static-import-and-then-dynamic-import-worker.js
testing/web-platform/tests/workers/modules/resources/static-import-worker.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -298034,26 +298034,46 @@
      {}
     ]
    ],
    "workers/interfaces/WorkerUtils/importScripts/undefined": [
     [
      {}
     ]
    ],
+   "workers/modules/resources/dynamic-import-and-then-static-import-worker.js": [
+    [
+     {}
+    ]
+   ],
+   "workers/modules/resources/dynamic-import-worker.js": [
+    [
+     {}
+    ]
+   ],
+   "workers/modules/resources/nested-dynamic-import-worker.js": [
+    [
+     {}
+    ]
+   ],
    "workers/modules/resources/nested-static-import-worker.js": [
     [
      {}
     ]
    ],
    "workers/modules/resources/post-message-on-load-worker.js": [
     [
      {}
     ]
    ],
+   "workers/modules/resources/static-import-and-then-dynamic-import-worker.js": [
+    [
+     {}
+    ]
+   ],
    "workers/modules/resources/static-import-worker.js": [
     [
      {}
     ]
    ],
    "workers/non-automated/application-cache-dedicated.html": [
     [
      {}
@@ -370290,28 +370310,28 @@
     ]
    ],
    "workers/interfaces/WorkerUtils/navigator/language.html": [
     [
      "/workers/interfaces/WorkerUtils/navigator/language.html",
      {}
     ]
    ],
+   "workers/modules/dedicated-worker-import.html": [
+    [
+     "/workers/modules/dedicated-worker-import.html",
+     {}
+    ]
+   ],
    "workers/modules/dedicated-worker-options-type.html": [
     [
      "/workers/modules/dedicated-worker-options-type.html",
      {}
     ]
    ],
-   "workers/modules/dedicated-worker-static-import.html": [
-    [
-     "/workers/modules/dedicated-worker-static-import.html",
-     {}
-    ]
-   ],
    "workers/name-property.html": [
     [
      "/workers/name-property.html",
      {}
     ]
    ],
    "workers/nested_worker.worker.js": [
     [
@@ -608825,34 +608845,50 @@
   "workers/interfaces/WorkerUtils/navigator/007.html": [
    "9b7b7485f1db37368824a593b2d6cbea46dad440",
    "testharness"
   ],
   "workers/interfaces/WorkerUtils/navigator/language.html": [
    "6bffa3be83d81e2faa93119e710e4fee93fb855e",
    "testharness"
   ],
+  "workers/modules/dedicated-worker-import.html": [
+   "752698b4f8f7298ca2ecc74d41887117a636118a",
+   "testharness"
+  ],
   "workers/modules/dedicated-worker-options-type.html": [
    "9f6f1be759beb885e2baa746e36ace83685f649b",
    "testharness"
   ],
-  "workers/modules/dedicated-worker-static-import.html": [
-   "d0d3dc37a8c061a1dc5213f8fe79e7f985c48b81",
-   "testharness"
+  "workers/modules/resources/dynamic-import-and-then-static-import-worker.js": [
+   "f4df69196f64cd81e92705186325004ac94db659",
+   "support"
+  ],
+  "workers/modules/resources/dynamic-import-worker.js": [
+   "444e313fe51923097e3672d88d0afd30aac5ecab",
+   "support"
+  ],
+  "workers/modules/resources/nested-dynamic-import-worker.js": [
+   "4ee05f3be8a1b41a9e2fa3e24d40ec5103f67eac",
+   "support"
   ],
   "workers/modules/resources/nested-static-import-worker.js": [
-   "eb76ec7e8a0f9df6de7114e3aa9100f8374fea8f",
+   "38ca86e8e32df51af7d848474f31a7b8ff9dc3aa",
    "support"
   ],
   "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-worker.js": [
-   "f3020118d7e499e0e910abc7a733e0b9c3cf1e5a",
+   "6d5fb2c553d2f32cdd16722a85bd65e0a172768c",
    "support"
   ],
   "workers/name-property.html": [
    "1c53fc1fdc2d6c8ed5592d832a18bdbd3bca541b",
    "testharness"
   ],
   "workers/nested_worker.worker.js": [
    "04898c40ac4ff943cc83674ca6126464513abbd6",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/workers/modules/dedicated-worker-import.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<title>DedicatedWorker: import</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+
+// Start a dedicated worker for |scriptURL| and wait until MessageEvents from
+// imported modules up to |expectedNumberOfImportedModules|.
+function RunImportTest(scriptURL, expectedNumberOfImportedModules) {
+  return new Promise(resolve => {
+    let numberOfImportedModules = 0;
+    const worker = new Worker(scriptURL, { type: 'module' });
+    worker.onmessage = e => {
+      if (e.data === 'LOADED')
+        ++numberOfImportedModules;
+      if (numberOfImportedModules === expectedNumberOfImportedModules)
+        resolve();
+    };
+  });
+}
+
+promise_test(() => {
+  return RunImportTest('resources/static-import-worker.js', 2);
+}, 'Test static import on DedicatedWorkerGlobalScope.');
+
+promise_test(() => {
+  return RunImportTest('resources/nested-static-import-worker.js', 3);
+}, 'Test nested static import on DedicatedWorkerGlobalScope.');
+
+promise_test(() => {
+  return RunImportTest(
+      'resources/static-import-and-then-dynamic-import-worker.js', 3);
+}, 'Test static import and then dynamic import on DedicatedWorkerGlobalScope.');
+
+promise_test(() => {
+  return RunImportTest('resources/dynamic-import-worker.js', 2);
+}, 'Test dynamic import on DedicatedWorkerGlobalScope.');
+
+promise_test(() => {
+  return RunImportTest('resources/nested-dynamic-import-worker.js', 3);
+}, 'Test nested dynamic import on DedicatedWorkerGlobalScope.');
+
+promise_test(() => {
+  return RunImportTest(
+      'resources/dynamic-import-and-then-static-import-worker.js', 3);
+}, 'Test dynamic import and then static import on DedicatedWorkerGlobalScope.');
+
+</script>
deleted file mode 100644
--- a/testing/web-platform/tests/workers/modules/dedicated-worker-static-import.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<title>DedicatedWorker: static import</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script>
-
-promise_test(() => {
-  const worker = new Worker('resources/static-import-worker.js',
-                            { type: 'module' });
-  return new Promise(resolve => worker.onmessage = resolve)
-      .then(msg_event => assert_equals(msg_event.data, 'LOADED'));
-}, 'Test static import on DedicatedWorkerGlobalScope.');
-
-promise_test(() => {
-  const worker = new Worker('resources/nested-static-import-worker.js',
-                            { type: 'module' });
-  return new Promise(resolve => worker.onmessage = resolve)
-      .then(msg_event => assert_equals(msg_event.data, 'LOADED'));
-}, 'Test nested static import on DedicatedWorkerGlobalScope.');
-
-</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/workers/modules/resources/dynamic-import-and-then-static-import-worker.js
@@ -0,0 +1,2 @@
+import('./static-import-worker.js')
+  .then(module => postMessage('LOADED'));
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/workers/modules/resources/dynamic-import-worker.js
@@ -0,0 +1,2 @@
+import('./post-message-on-load-worker.js')
+  .then(module => postMessage('LOADED'));
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/workers/modules/resources/nested-dynamic-import-worker.js
@@ -0,0 +1,2 @@
+import('./dynamic-import-worker.js')
+  .then(module => postMessage('LOADED'));
--- a/testing/web-platform/tests/workers/modules/resources/nested-static-import-worker.js
+++ b/testing/web-platform/tests/workers/modules/resources/nested-static-import-worker.js
@@ -1,1 +1,2 @@
 import './static-import-worker.js';
+postMessage('LOADED')
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/workers/modules/resources/static-import-and-then-dynamic-import-worker.js
@@ -0,0 +1,2 @@
+import './dynamic-import-worker.js';
+postMessage('LOADED');
--- a/testing/web-platform/tests/workers/modules/resources/static-import-worker.js
+++ b/testing/web-platform/tests/workers/modules/resources/static-import-worker.js
@@ -1,1 +1,2 @@
 import './post-message-on-load-worker.js';
+postMessage('LOADED');