Skip to content

Commit

Permalink
test: check that this != new.target in addon
Browse files Browse the repository at this point in the history
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 <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
bnoordhuis authored and MylesBorins committed Oct 11, 2017
1 parent db0ba97 commit 88f69d3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/addons/new-target/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 88f69d3

Please sign in to comment.