Commit 5d5cb88c authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Chromium LUCI CQ

[blink] Support top-level await in synthetic modules

When top-level await is enabled, all module script evaluation is
expected to return a Promise. This CL changes
ValueWrapperSyntheticModuleScripts (CSS and JSON) to return a Promise
that's resolved to undefined.

Bug: v8:1154497
Change-Id: I92114d42f0080918e9e61bf1b62d5eda4cffdabc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568823
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: default avatarHiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833790}
parent 1637fe62
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/core/script/value_wrapper_synthetic_module_script.h" #include "third_party/blink/renderer/core/script/value_wrapper_synthetic_module_script.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/web_vector.h" #include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_css_style_sheet_init.h" #include "third_party/blink/renderer/bindings/core/v8/v8_css_style_sheet_init.h"
...@@ -199,7 +200,20 @@ v8::MaybeLocal<v8::Value> ValueWrapperSyntheticModuleScript::EvaluationSteps( ...@@ -199,7 +200,20 @@ v8::MaybeLocal<v8::Value> ValueWrapperSyntheticModuleScript::EvaluationSteps(
DCHECK(!try_catch.HasCaught()); DCHECK(!try_catch.HasCaught());
DCHECK(!result.IsNothing() && result.FromJust()); DCHECK(!result.IsNothing() && result.FromJust());
return v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); if (base::FeatureList::IsEnabled(features::kTopLevelAwait)) {
v8::Local<v8::Promise::Resolver> promise_resolver;
if (!v8::Promise::Resolver::New(context).ToLocal(&promise_resolver)) {
if (!isolate->IsExecutionTerminating()) {
LOG(FATAL) << "Cannot recover from failure to create a new "
"v8::Promise::Resolver object (OOM?)";
}
return v8::MaybeLocal<v8::Value>();
}
promise_resolver->Resolve(context, v8::Undefined(isolate)).ToChecked();
return promise_resolver->GetPromise();
}
return v8::Undefined(isolate);
} }
void ValueWrapperSyntheticModuleScript::Trace(Visitor* visitor) const { void ValueWrapperSyntheticModuleScript::Trace(Visitor* visitor) const {
......
...@@ -1592,6 +1592,7 @@ crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dy ...@@ -1592,6 +1592,7 @@ crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dy
crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html [ Pass ] crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-immediate-promise.html [ Pass ]
crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html [ Pass ] crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-import.html [ Pass ]
crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html [ Pass ] crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/webappapis/dynamic-markup-insertion/document-write/module-tla-promise.html [ Pass ]
crbug.com/1022182 virtual/module-top-level-await/external/wpt/html/semantics/scripting-1/the-script-element/json-module/parse-error.tentative.html [ Skip ]
crbug.com/1024331 external/wpt/css/css-text/hyphens/hyphens-out-of-flow-001.html [ Failure ] crbug.com/1024331 external/wpt/css/css-text/hyphens/hyphens-out-of-flow-001.html [ Failure ]
crbug.com/1024331 external/wpt/css/css-text/hyphens/hyphens-out-of-flow-002.html [ Failure ] crbug.com/1024331 external/wpt/css/css-text/hyphens/hyphens-out-of-flow-002.html [ Failure ]
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"bases": [ "bases": [
"external/wpt/html/webappapis/dynamic-markup-insertion/document-write", "external/wpt/html/webappapis/dynamic-markup-insertion/document-write",
"external/wpt/html/semantics/scripting-1/the-script-element/module", "external/wpt/html/semantics/scripting-1/the-script-element/module",
"external/wpt/html/semantics/scripting-1/the-script-element/json-module",
"external/wpt/service-workers/service-worker/registration-script-module.https.html", "external/wpt/service-workers/service-worker/registration-script-module.https.html",
"external/wpt/service-workers/service-worker/update-registration-with-type.https.html", "external/wpt/service-workers/service-worker/update-registration-with-type.https.html",
"external/wpt/workers/Worker-terminate-forever-during-evaluation.html", "external/wpt/workers/Worker-terminate-forever-during-evaluation.html",
...@@ -14,7 +15,7 @@ ...@@ -14,7 +15,7 @@
"fast/loader/invalid-module-specifier.html", "fast/loader/invalid-module-specifier.html",
"http/tests/devtools/isolated-code-cache/" "http/tests/devtools/isolated-code-cache/"
], ],
"args": ["--enable-features=TopLevelAwait"] "args": ["--enable-features=TopLevelAwait,JSONModules"]
}, },
{ {
"prefix": "disable-accept-language-header", "prefix": "disable-accept-language-header",
......
This is a testharness.js-based test.
PASS Javascript importing JSON Module should load within the context of a service worker
PASS JSON Modules should load within the context of a service worker
PASS JSON Module dynamic import should not load within the context of a service worker
Harness: the test ran to completion.
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.
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.
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.
This is a testharness.js-based test.
PASS utf-8
PASS shift-jis
PASS windows-1252
PASS utf-7
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS text/json
PASS application/json
FAIL text/html+json assert_unreached: [object Event] Reached unreachable code
FAIL image/svg+json assert_unreached: [object Event] Reached unreachable code
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