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

Unified Diff: third_party/WebKit/Source/core/dom/ModulatorImpl.cpp

Issue 2819733002: Implement ModuleScript::RunScript() (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/core/dom/ModulatorImpl.cpp
diff --git a/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
index 33362773ea16c138c8d30fc7a425043ad4fda375..51f492a00337f8e95532c364e3590ae0b0a45f40 100644
--- a/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
+++ b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
@@ -134,6 +134,33 @@ Vector<String> ModulatorImpl::ModuleRequestsFromScriptModule(
return script_module.ModuleRequests(script_state_.Get());
}
+void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) {
+ // https://html.spec.whatwg.org/#run-a-module-script
+ ScriptState::Scope scope(script_state_.Get());
+
+ // 3. "If s's instantiation state is "errored", then report the exception
+ // given by s's instantiation error for s and abort these steps."
+ if (module_script->InstantiationState() ==
+ ModuleInstantiationState::kErrored) {
+ v8::Isolate* isolate = script_state_->GetIsolate();
+ V8ThrowException::ThrowException(
+ isolate, module_script->CreateInstantiationError(isolate));
+ return;
+ }
+
+ // 4. "Assert: s's instantiation state is "instantiated" (and thus its
+ // module record is not null)."
+ CHECK_EQ(module_script->InstantiationState(),
+ ModuleInstantiationState::kInstantiated);
+
+ // 5. "Let record be s's module record."
+ const ScriptModule& record = module_script->Record();
+ CHECK(!record.IsNull());
+
+ // 6.--9.?
+ record.Evaluate(script_state_.Get());
+}
+
DEFINE_TRACE(ModulatorImpl) {
Modulator::Trace(visitor);
visitor->Trace(execution_context_);

Powered by Google App Engine
This is Rietveld 408576698