From 88f69d3ec32b201674c64740d4761a67288e567f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 29 Sep 2017 12:26:07 +0200 Subject: [PATCH] test: check that this != new.target in addon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- test/addons/new-target/binding.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/addons/new-target/binding.cc b/test/addons/new-target/binding.cc index 5491c18c6e99af..3ae2aca7c2ef95 100644 --- a/test/addons/new-target/binding.cc +++ b/test/addons/new-target/binding.cc @@ -3,7 +3,11 @@ namespace { -inline void NewClass(const v8::FunctionCallbackInfo&) {} +inline void NewClass(const v8::FunctionCallbackInfo& 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 binding) { auto isolate = binding->GetIsolate();