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>
pull/15723/head
Ben Noordhuis 2017-09-29 12:26:07 +02:00 committed by Ruben Bridgewater
parent c8a21436c9
commit 9e9c83ea95
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
1 changed files with 5 additions and 1 deletions

View File

@ -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();