Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 9337708dcf0f7b3985b580c2208edde485fc88e5..bfb5322fb766801063da2a544dc0f56390b8196b 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -2052,6 +2052,42 @@ Local<UnboundScript> Script::GetUnboundScript() { |
i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); |
} |
+// static |
+bool Module::FinishDynamicImportSuccess(Local<Context> context, |
+ Local<Promise> promise, |
+ Local<Module> module) { |
+ PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportSuccess); |
+ i::Handle<i::Module> module_obj = Utils::OpenHandle(*module); |
+ i::Handle<i::JSModuleNamespace> module_namespace = |
+ i::Module::GetModuleNamespace(module_obj); |
+ i::Handle<i::Object> argv[] = {Utils::OpenHandle(*promise), module_namespace}; |
+ has_pending_exception = |
+ i::Execution::Call(isolate, isolate->promise_resolve(), |
+ isolate->factory()->undefined_value(), arraysize(argv), |
+ argv) |
+ .is_null(); |
+ RETURN_ON_FAILED_EXECUTION_BOOL(); |
+ return true; |
+} |
+ |
+// static |
+bool Module::FinishDynamicImportFailure(Local<Context> context, |
+ Local<Promise> promise, |
+ Local<Value> exception) { |
+ PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportFailure); |
+ // We pass true to trigger the debugger's on exception handler. |
+ i::Handle<i::Object> argv[] = {Utils::OpenHandle(*promise), |
+ Utils::OpenHandle(*exception), |
+ isolate->factory()->ToBoolean(true)}; |
+ has_pending_exception = |
+ i::Execution::Call(isolate, isolate->promise_internal_reject(), |
+ isolate->factory()->undefined_value(), arraysize(argv), |
+ argv) |
+ .is_null(); |
+ RETURN_ON_FAILED_EXECUTION_BOOL(); |
+ return true; |
+} |
+ |
int Module::GetModuleRequestsLength() const { |
i::Handle<i::Module> self = Utils::OpenHandle(this); |
return self->info()->module_requests()->length(); |
@@ -8185,6 +8221,12 @@ Isolate* Isolate::New(const Isolate::CreateParams& params) { |
isolate->set_api_external_references(params.external_references); |
isolate->set_allow_atomics_wait(params.allow_atomics_wait); |
+ |
+ if (params.host_import_module_dynamically_callback_ != nullptr) { |
+ isolate->SetHostImportModuleDynamicallyCallback( |
+ params.host_import_module_dynamically_callback_); |
+ } |
+ |
SetResourceConstraints(isolate, params.constraints); |
// TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. |
Isolate::Scope isolate_scope(v8_isolate); |