Browse Source

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: https://github.com/nodejs/node/pull/15681
Refs: https://github.com/nodejs/node-addon-api/issues/142
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
v6.x-staging
Ben Noordhuis 7 years ago
committed by Myles Borins
parent
commit
313554a792
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 6
      test/addons/new-target/binding.cc

6
test/addons/new-target/binding.cc

@ -3,7 +3,11 @@
namespace {
inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>&) {}
inline void NewClass(const v8::FunctionCallbackInfo<v8::Value>& args) {
// this != new.target since we are being invoked through super().
assert(args.IsConstructCall());
assert(!args.This()->StrictEquals(args.NewTarget()));
}
inline void Initialize(v8::Local<v8::Object> binding) {
auto isolate = binding->GetIsolate();

Loading…
Cancel
Save