@@ -23693,7 +23693,9 @@ v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackFail(
2369323693
2369423694v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackSetExport(
2369523695 Local<Context> context, Local<Module> module) {
23696- module->SetSyntheticModuleExport(v8_str("test_export"), v8_num(42));
23696+ Maybe<bool> set_export_result = module->SetSyntheticModuleExport(
23697+ context->GetIsolate(), v8_str("test_export"), v8_num(42));
23698+ CHECK(set_export_result.FromJust());
2369723699 return v8::Undefined(reinterpret_cast<v8::Isolate*>(context->GetIsolate()));
2369823700}
2369923701
@@ -23900,7 +23902,9 @@ TEST(SyntheticModuleSetExports) {
2390023902 // undefined.
2390123903 CHECK(foo_cell->value().IsUndefined());
2390223904
23903- module->SetSyntheticModuleExport(foo_string, bar_string);
23905+ Maybe<bool> set_export_result =
23906+ module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
23907+ CHECK(set_export_result.FromJust());
2390423908
2390523909 // After setting the export the Cell should still have the same idenitity.
2390623910 CHECK_EQ(exports->Lookup(v8::Utils::OpenHandle(*foo_string)), *foo_cell);
@@ -23911,6 +23915,34 @@ TEST(SyntheticModuleSetExports) {
2391123915 ->Equals(*v8::Utils::OpenHandle(*bar_string)));
2391223916}
2391323917
23918+ TEST(SyntheticModuleSetMissingExport) {
23919+ LocalContext env;
23920+ v8::Isolate* isolate = env->GetIsolate();
23921+ auto i_isolate = reinterpret_cast<i::Isolate*>(isolate);
23922+ v8::Isolate::Scope iscope(isolate);
23923+ v8::HandleScope scope(isolate);
23924+ v8::Local<v8::Context> context = v8::Context::New(isolate);
23925+ v8::Context::Scope cscope(context);
23926+
23927+ Local<String> foo_string = v8_str("foo");
23928+ Local<String> bar_string = v8_str("bar");
23929+
23930+ Local<Module> module = CreateAndInstantiateSyntheticModule(
23931+ isolate, v8_str("SyntheticModuleSetExports-TestSyntheticModule"), context,
23932+ std::vector<v8::Local<v8::String>>(),
23933+ UnexpectedSyntheticModuleEvaluationStepsCallback);
23934+
23935+ i::Handle<i::SyntheticModule> i_module =
23936+ i::Handle<i::SyntheticModule>::cast(v8::Utils::OpenHandle(*module));
23937+ i::Handle<i::ObjectHashTable> exports(i_module->exports(), i_isolate);
23938+
23939+ TryCatch try_catch(isolate);
23940+ Maybe<bool> set_export_result =
23941+ module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
23942+ CHECK(set_export_result.IsNothing());
23943+ CHECK(try_catch.HasCaught());
23944+ }
23945+
2391423946TEST(SyntheticModuleEvaluationStepsNoThrow) {
2391523947 synthetic_module_callback_count = 0;
2391623948 LocalContext env;
0 commit comments