Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp

Issue 2781713003: Enable module scripts in ScriptLoader (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
index fda3bcb4b64e543789bca503174aa168bc90f3d9..894917f010dc48896fc4b0bcceecd3aa2275f00f 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptModule.cpp
@@ -6,6 +6,7 @@
#include "bindings/core/v8/V8Binding.h"
#include "core/dom/Modulator.h"
+#include "core/dom/ModuleScript.h"
#include "core/dom/ScriptModuleResolver.h"
namespace blink {
@@ -55,13 +56,35 @@ ScriptValue ScriptModule::Instantiate(ScriptState* script_state) {
return ScriptValue();
}
-void ScriptModule::Evaluate(ScriptState* script_state) {
+// https://html.spec.whatwg.org/#run-a-module-script
+void ScriptModule::Evaluate(ScriptState* script_state,
+ const ModuleScript* moduleScript) {
v8::Isolate* isolate = script_state->GetIsolate();
v8::TryCatch try_catch(isolate);
try_catch.SetVerbose(true);
v8::Local<v8::Value> result;
+
+ // 3. "If s's instantiation state is "errored", then report the exception
hiroshige 2017/04/12 19:57:05 Where should this logic be placed? (Note that this
kouhei (in TOK) 2017/04/13 02:28:36 I'd put this logic in ModulatorImpl
hiroshige 2017/04/13 23:53:15 Splitted the ModulatorImpl change into https://cod
+ // given by s's instantiation error for s and abort these steps."
+ if (moduleScript->InstantiationState() ==
+ ModuleInstantiationState::kErrored) {
+ V8ThrowException::ThrowException(
+ isolate, moduleScript->CreateInstantiationError(isolate));
+ return;
+ }
+
+ // 4. "Assert: s's instantiation state is "instantiated" (and thus its
+ // module record is not null)."
+ DCHECK_EQ(moduleScript->InstantiationState(),
+ ModuleInstantiationState::kInstantiated);
+
+ // 5. "Let record be s's module record."
+ const ScriptModule& record = moduleScript->Record();
+ DCHECK(!record.IsNull());
+
+ // 6.--9.?
if (!V8Call(
- V8ScriptRunner::EvaluateModule(module_->NewLocal(isolate),
+ V8ScriptRunner::EvaluateModule(record.module_->NewLocal(isolate),
script_state->GetContext(), isolate),
result, try_catch)) {
// TODO(adamk): report error

Powered by Google App Engine
This is Rietveld 408576698