Commit 8fe78d47 authored by Eriko Kurimoto's avatar Eriko Kurimoto Committed by Commit Bot

SharedWorker: Support dynamic import with 'module' type on SharedWorker

This change is still behind the flag.

Bug: 824646
Change-Id: I8a82c9b1fe499c4cf8ba182c308054c5dc9e5d0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2009598
Commit-Queue: Eriko Kurimoto <elkurin@google.com>
Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733547}
parent 286540be
...@@ -43,8 +43,14 @@ bool WorkerModulatorImpl::IsDynamicImportForbidden(String* reason) { ...@@ -43,8 +43,14 @@ bool WorkerModulatorImpl::IsDynamicImportForbidden(String* reason) {
return false; return false;
} }
// TODO(nhiroki): Support module loading for SharedWorker and Service Worker. // TODO(https://crbug.com/824646): Remove this flag check once module loading
// (https://crbug.com/680046) // for SharedWorker is enabled by default.
if (GetExecutionContext()->IsSharedWorkerGlobalScope() &&
RuntimeEnabledFeatures::ModuleSharedWorkerEnabled()) {
return false;
}
// TODO(https://crbug.com/824647): Support module loading for Service Worker.
*reason = *reason =
"Module scripts are not supported on WorkerGlobalScope yet (see " "Module scripts are not supported on WorkerGlobalScope yet (see "
"https://crbug.com/680046)."; "https://crbug.com/680046).";
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Non-object: null promise_test: Unhandled rejection with value: object "TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046)." FAIL Non-object: null promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/scripting-1/the-script-element/json-module/null.json"
FAIL Non-object: true promise_test: Unhandled rejection with value: object "TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046)." FAIL Non-object: true promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/scripting-1/the-script-element/json-module/true.json"
FAIL Non-object: false promise_test: Unhandled rejection with value: object "TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046)." FAIL Non-object: false promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/scripting-1/the-script-element/json-module/false.json"
FAIL Non-object: string promise_test: Unhandled rejection with value: object "TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046)." FAIL Non-object: string promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/scripting-1/the-script-element/json-module/string.json"
FAIL Non-object: array promise_test: Unhandled rejection with value: object "TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046)." FAIL Non-object: array promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch dynamically imported module: http://web-platform.test:8001/html/semantics/scripting-1/the-script-element/json-module/array.json"
Harness: the test ran to completion. Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Static import.
PASS Nested static import.
FAIL Static import and then dynamic import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL Dynamic import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL Nested dynamic import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL Dynamic import and then static import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL eval(import()). assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Static import.
PASS Nested static import.
FAIL Static import and then dynamic import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL Dynamic import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL Nested dynamic import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL Dynamic import and then static import. assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
FAIL eval(import()). assert_array_equals: value is "Failed to do dynamic import: TypeError: Module scripts are not supported on WorkerGlobalScope yet (see https://crbug.com/680046).", expected array
Harness: the test ran to completion.
<!DOCTYPE html>
<title>Worker: Dynamic import() on SharedWorkerGlobalScope</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
// This test should not be upstreamed to WPT because this tests Chrome-specific
// behavior.
promise_test(() => {
const worker = new SharedWorker('resources/shared-worker-dynamic-import.js');
return new Promise(resolve => worker.port.onmessage = resolve)
.then(msg_event => {
assert_equals(msg_event.data.name, 'TypeError');
assert_equals(msg_event.data.message,
'Module scripts are not supported on WorkerGlobalScope ' +
'yet (see https://crbug.com/680046).');
});
}, 'Dynamic import() on SharedWorkerGlobalScope should reject the promise.');
</script>
This is a testharness.js-based test.
PASS Non-object: null
PASS Non-object: true
PASS Non-object: false
PASS Non-object: string
PASS Non-object: array
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment