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

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

Issue 2838933003: [not-for-commit] kitsune changes + pending kouhei changes (Closed)
Patch Set: 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 b41d3a4038568b5a5c0940a95339b1d9484e49ce..32387dc75aa0cbd412ebac54d2365f0e7b5ba4fd 100644
--- a/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
+++ b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
@@ -128,6 +128,14 @@ ScriptValue ModulatorImpl::InstantiateModule(ScriptModule script_module) {
return script_module.Instantiate(script_state_.Get());
}
+ScriptValue ModulatorImpl::GetInstantiationError(
+ const ModuleScript* module_script) {
+ ScriptState::Scope scope(script_state_.Get());
+ return ScriptValue(
+ script_state_.Get(),
+ module_script->CreateInstantiationError(script_state_->GetIsolate()));
+}
+
Vector<String> ModulatorImpl::ModuleRequestsFromScriptModule(
ScriptModule script_module) {
ScriptState::Scope scope(script_state_.Get());
@@ -138,6 +146,43 @@ inline ExecutionContext* ModulatorImpl::GetExecutionContext() const {
return ExecutionContext::From(script_state_.Get());
}
+void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) {
+ // https://html.spec.whatwg.org/#run-a-module-script
+
+ // 1. "Let settings be the settings object of s."
+ // The settings object is |this|.
+
+ // 2. "Check if we can run script with settings.
+ // If this returns "do not run" then abort these steps."
+ if (!GetExecutionContext()->CanExecuteScripts(kAboutToExecuteScript))
+ return;
+
+ 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."
+ ModuleInstantiationState instantiationState =
+ module_script->InstantiationState();
+ if (instantiationState == ModuleInstantiationState::kErrored) {
+ v8::Isolate* isolate = script_state_->GetIsolate();
+ ScriptModule::ReportException(
+ script_state_.Get(), module_script->CreateInstantiationError(isolate),
+ module_script->BaseURL().GetString());
+ return;
+ }
+
+ // 4. "Assert: s's instantiation state is "instantiated" (and thus its
+ // module record is not null)."
+ CHECK_EQ(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(fetcher_);

Powered by Google App Engine
This is Rietveld 408576698