@@ -23654,7 +23654,9 @@ v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackFail(
2365423654
2365523655v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackSetExport(
2365623656 Local<Context> context, Local<Module> module) {
23657- module->SetSyntheticModuleExport(v8_str("test_export"), v8_num(42));
23657+ Maybe<bool> set_export_result = module->SetSyntheticModuleExport(
23658+ context->GetIsolate(), v8_str("test_export"), v8_num(42));
23659+ CHECK(set_export_result.FromJust());
2365823660 return v8::Undefined(reinterpret_cast<v8::Isolate*>(context->GetIsolate()));
2365923661}
2366023662
@@ -23861,7 +23863,9 @@ TEST(SyntheticModuleSetExports) {
2386123863 // undefined.
2386223864 CHECK(foo_cell->value().IsUndefined());
2386323865
23864- module->SetSyntheticModuleExport(foo_string, bar_string);
23866+ Maybe<bool> set_export_result =
23867+ module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
23868+ CHECK(set_export_result.FromJust());
2386523869
2386623870 // After setting the export the Cell should still have the same idenitity.
2386723871 CHECK_EQ(exports->Lookup(v8::Utils::OpenHandle(*foo_string)), *foo_cell);
@@ -23872,6 +23876,34 @@ TEST(SyntheticModuleSetExports) {
2387223876 ->Equals(*v8::Utils::OpenHandle(*bar_string)));
2387323877}
2387423878
23879+ TEST(SyntheticModuleSetMissingExport) {
23880+ LocalContext env;
23881+ v8::Isolate* isolate = env->GetIsolate();
23882+ auto i_isolate = reinterpret_cast<i::Isolate*>(isolate);
23883+ v8::Isolate::Scope iscope(isolate);
23884+ v8::HandleScope scope(isolate);
23885+ v8::Local<v8::Context> context = v8::Context::New(isolate);
23886+ v8::Context::Scope cscope(context);
23887+
23888+ Local<String> foo_string = v8_str("foo");
23889+ Local<String> bar_string = v8_str("bar");
23890+
23891+ Local<Module> module = CreateAndInstantiateSyntheticModule(
23892+ isolate, v8_str("SyntheticModuleSetExports-TestSyntheticModule"), context,
23893+ std::vector<v8::Local<v8::String>>(),
23894+ UnexpectedSyntheticModuleEvaluationStepsCallback);
23895+
23896+ i::Handle<i::SyntheticModule> i_module =
23897+ i::Handle<i::SyntheticModule>::cast(v8::Utils::OpenHandle(*module));
23898+ i::Handle<i::ObjectHashTable> exports(i_module->exports(), i_isolate);
23899+
23900+ TryCatch try_catch(isolate);
23901+ Maybe<bool> set_export_result =
23902+ module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
23903+ CHECK(set_export_result.IsNothing());
23904+ CHECK(try_catch.HasCaught());
23905+ }
23906+
2387523907TEST(SyntheticModuleEvaluationStepsNoThrow) {
2387623908 synthetic_module_callback_count = 0;
2387723909 LocalContext env;
0 commit comments