OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/ModulatorImpl.h" | 5 #include "core/dom/ModulatorImpl.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
9 #include "core/dom/ModuleMap.h" | 9 #include "core/dom/ModuleMap.h" |
10 #include "core/dom/ModuleScript.h" | 10 #include "core/dom/ModuleScript.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 ScriptState::Scope scope(script_state_.Get()); | 127 ScriptState::Scope scope(script_state_.Get()); |
128 return script_module.Instantiate(script_state_.Get()); | 128 return script_module.Instantiate(script_state_.Get()); |
129 } | 129 } |
130 | 130 |
131 Vector<String> ModulatorImpl::ModuleRequestsFromScriptModule( | 131 Vector<String> ModulatorImpl::ModuleRequestsFromScriptModule( |
132 ScriptModule script_module) { | 132 ScriptModule script_module) { |
133 ScriptState::Scope scope(script_state_.Get()); | 133 ScriptState::Scope scope(script_state_.Get()); |
134 return script_module.ModuleRequests(script_state_.Get()); | 134 return script_module.ModuleRequests(script_state_.Get()); |
135 } | 135 } |
136 | 136 |
| 137 void ModulatorImpl::ExecuteModule(const ModuleScript* module_script) { |
| 138 // https://html.spec.whatwg.org/#run-a-module-script |
| 139 ScriptState::Scope scope(script_state_.Get()); |
| 140 |
| 141 // 3. "If s's instantiation state is "errored", then report the exception |
| 142 // given by s's instantiation error for s and abort these steps." |
| 143 if (module_script->InstantiationState() == |
| 144 ModuleInstantiationState::kErrored) { |
| 145 v8::Isolate* isolate = script_state_->GetIsolate(); |
| 146 V8ThrowException::ThrowException( |
| 147 isolate, module_script->CreateInstantiationError(isolate)); |
| 148 return; |
| 149 } |
| 150 |
| 151 // 4. "Assert: s's instantiation state is "instantiated" (and thus its |
| 152 // module record is not null)." |
| 153 CHECK_EQ(module_script->InstantiationState(), |
| 154 ModuleInstantiationState::kInstantiated); |
| 155 |
| 156 // 5. "Let record be s's module record." |
| 157 const ScriptModule& record = module_script->Record(); |
| 158 CHECK(!record.IsNull()); |
| 159 |
| 160 // 6.--9.? |
| 161 record.Evaluate(script_state_.Get()); |
| 162 } |
| 163 |
137 DEFINE_TRACE(ModulatorImpl) { | 164 DEFINE_TRACE(ModulatorImpl) { |
138 Modulator::Trace(visitor); | 165 Modulator::Trace(visitor); |
139 visitor->Trace(execution_context_); | 166 visitor->Trace(execution_context_); |
140 visitor->Trace(fetcher_); | 167 visitor->Trace(fetcher_); |
141 visitor->Trace(map_); | 168 visitor->Trace(map_); |
142 visitor->Trace(loader_registry_); | 169 visitor->Trace(loader_registry_); |
143 visitor->Trace(tree_linker_registry_); | 170 visitor->Trace(tree_linker_registry_); |
144 visitor->Trace(script_module_resolver_); | 171 visitor->Trace(script_module_resolver_); |
145 } | 172 } |
146 | 173 |
147 DEFINE_TRACE_WRAPPERS(ModulatorImpl) { | 174 DEFINE_TRACE_WRAPPERS(ModulatorImpl) { |
148 visitor->TraceWrappers(map_); | 175 visitor->TraceWrappers(map_); |
149 } | 176 } |
150 | 177 |
151 } // namespace blink | 178 } // namespace blink |
OLD | NEW |