Chromium Code Reviews| 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..5732b41b0a55b527fc7ff7edf5107c90c7bcfada 100644 |
| --- a/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp |
| +++ b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp |
| @@ -138,6 +138,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()); |
|
kouhei (in TOK)
2017/04/26 00:57:42
This is actually step 6 + 9.
Note that we can't mo
hiroshige
2017/04/26 17:25:16
Done.
|
| + |
| + // 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.? |
|
kouhei (in TOK)
2017/04/26 00:57:42
This is Step 7+8.
hiroshige
2017/04/26 17:25:16
Done.
|
| + record.Evaluate(script_state_.Get()); |
| +} |
| + |
| DEFINE_TRACE(ModulatorImpl) { |
| Modulator::Trace(visitor); |
| visitor->Trace(fetcher_); |