Skip to content

Commit a75f042

Browse files
bnoordhuisMylesBorins
authored andcommitted
test: check that this != new.target in addon
Add two checks that are there for expository reasons as much as they are sanity checks. PR-URL: #15681 Refs: nodejs/node-addon-api#142 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 7f56d24 commit a75f042

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/addons/new-target/binding.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
namespace {
55

6-
inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>&) {}
6+
inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>& args) {
7+
// this != new.target since we are being invoked through super().
8+
assert(args.IsConstructCall());
9+
assert(!args.This()->StrictEquals(args.NewTarget()));
10+
}
711

812
inline void Initialize(v8::Local<v8::Object> binding) {
913
auto isolate = binding->GetIsolate();

0 commit comments

Comments
 (0)