summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/test-api.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-10-28 11:12:22 +0100
committerMichaël Zasso <targos@protonmail.com>2019-11-08 15:50:51 +0100
commitd9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75 (patch)
treec1c9b3dcb745a0c7bd9cc71802692816448b2180 /deps/v8/test/cctest/test-api.cc
parent53e925a5605675c0f534128c0a317f232229b0f3 (diff)
downloadandroid-node-v8-d9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75.tar.gz
android-node-v8-d9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75.tar.bz2
android-node-v8-d9fab1fdb76ae3a69b5812a7f2190cf3e58f6d75.zip
deps: V8: cherry-pick 777fa98
Original commit message: Make SetSyntheticModuleExport throw instead of crash for nonexistent export name Per spec, Module::SetSyntheticModuleExport should throw a ReferenceError when called with an export name that was not supplied when constructing that SyntheticModule. Instead, the current implementation crashes with a failed CHECK(). Add a new Module::SyntheticModuleSetExport that throws (without an ensuing crash) for this case, and deprecate the old Module::SetSyntheticModuleExport. Bug: v8:9828 Change-Id: I3b3d353064c3851882781818099bd8f6ee74c809 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1860996 Reviewed-by: Adam Klein <adamk@chromium.org> Reviewed-by: Georg Neis <neis@chromium.org> Commit-Queue: Dan Clark <daniec@microsoft.com> Cr-Commit-Position: refs/heads/master@{#64438} Refs: https://github.com/v8/v8/commit/777fa98cc47ac32f0fde3d9aafd830949deb5d23 PR-URL: https://github.com/nodejs/node/pull/30020 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/test/cctest/test-api.cc')
-rw-r--r--deps/v8/test/cctest/test-api.cc36
1 files changed, 34 insertions, 2 deletions
diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc
index 1daa19402e..7da247e3ab 100644
--- a/deps/v8/test/cctest/test-api.cc
+++ b/deps/v8/test/cctest/test-api.cc
@@ -23721,7 +23721,9 @@ v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackFail(
v8::MaybeLocal<Value> SyntheticModuleEvaluationStepsCallbackSetExport(
Local<Context> context, Local<Module> module) {
- module->SetSyntheticModuleExport(v8_str("test_export"), v8_num(42));
+ Maybe<bool> set_export_result = module->SetSyntheticModuleExport(
+ context->GetIsolate(), v8_str("test_export"), v8_num(42));
+ CHECK(set_export_result.FromJust());
return v8::Undefined(reinterpret_cast<v8::Isolate*>(context->GetIsolate()));
}
@@ -23940,7 +23942,9 @@ TEST(SyntheticModuleSetExports) {
// undefined.
CHECK(foo_cell->value().IsUndefined());
- module->SetSyntheticModuleExport(foo_string, bar_string);
+ Maybe<bool> set_export_result =
+ module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
+ CHECK(set_export_result.FromJust());
// After setting the export the Cell should still have the same idenitity.
CHECK_EQ(exports->Lookup(v8::Utils::OpenHandle(*foo_string)), *foo_cell);
@@ -23951,6 +23955,34 @@ TEST(SyntheticModuleSetExports) {
->Equals(*v8::Utils::OpenHandle(*bar_string)));
}
+TEST(SyntheticModuleSetMissingExport) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ auto i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ v8::Isolate::Scope iscope(isolate);
+ v8::HandleScope scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope cscope(context);
+
+ Local<String> foo_string = v8_str("foo");
+ Local<String> bar_string = v8_str("bar");
+
+ Local<Module> module = CreateAndInstantiateSyntheticModule(
+ isolate, v8_str("SyntheticModuleSetExports-TestSyntheticModule"), context,
+ std::vector<v8::Local<v8::String>>(),
+ UnexpectedSyntheticModuleEvaluationStepsCallback);
+
+ i::Handle<i::SyntheticModule> i_module =
+ i::Handle<i::SyntheticModule>::cast(v8::Utils::OpenHandle(*module));
+ i::Handle<i::ObjectHashTable> exports(i_module->exports(), i_isolate);
+
+ TryCatch try_catch(isolate);
+ Maybe<bool> set_export_result =
+ module->SetSyntheticModuleExport(isolate, foo_string, bar_string);
+ CHECK(set_export_result.IsNothing());
+ CHECK(try_catch.HasCaught());
+}
+
TEST(SyntheticModuleEvaluationStepsNoThrow) {
synthetic_module_callback_count = 0;
LocalContext env;