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 |