| 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..0de68c9d76a278de233bc2435d7a2d5e549c8fe8 100644
|
| --- a/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/ModulatorImpl.cpp
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "core/dom/ModulatorImpl.h"
|
|
|
| +#include "bindings/core/v8/V8Binding.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ExecutionContext.h"
|
| #include "core/dom/ModuleMap.h"
|
| @@ -15,6 +16,7 @@
|
| #include "core/loader/modulescript/ModuleScriptLoaderRegistry.h"
|
| #include "core/loader/modulescript/ModuleTreeLinkerRegistry.h"
|
| #include "platform/loader/fetch/ResourceFetcher.h"
|
| +#include "v8/include/v8.h"
|
|
|
| namespace blink {
|
|
|
| @@ -134,6 +136,52 @@ 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."
|
| + printf("Exec module %p\n", module_script);
|
| + ModuleInstantiationState instantiationState =
|
| + module_script->InstantiationState();
|
| + if (instantiationState == ModuleInstantiationState::kErrored) {
|
| + v8::Isolate* isolate = script_state_->GetIsolate();
|
| +
|
| + v8::TryCatch try_catch(isolate);
|
| + try_catch.SetVerbose(true);
|
| +
|
| + // TODO(hiroshige): fix below
|
| + AccessControlStatus access_control_status = kSharableCrossOrigin;
|
| + v8::ScriptOrigin origin(
|
| + V8String(isolate, "fixme_get_this_info_from_module_script.js"),
|
| + v8::Integer::New(isolate, 0), // line_offset
|
| + v8::Integer::New(isolate, 0), // col_offset
|
| + V8Boolean(access_control_status == kSharableCrossOrigin, isolate),
|
| + v8::Local<v8::Integer>(), // script id
|
| + V8String(isolate, ""), // source_map_url
|
| + V8Boolean(access_control_status == kOpaqueResource, isolate),
|
| + V8Boolean(false, isolate), // is_wasm
|
| + V8Boolean(false, isolate)); // is_module
|
| + // ^^^ is_module = false to compile a fragment that throws exception
|
| +
|
| + V8ScriptRunner::ThrowException(
|
| + isolate, module_script->CreateInstantiationError(isolate), origin);
|
| + 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());
|
| +}
|
| +
|
| inline ExecutionContext* ModulatorImpl::GetExecutionContext() const {
|
| return ExecutionContext::From(script_state_.Get());
|
| }
|
|
|