From 313554a7924943fa6f6eb60f4ccea0800ac60846 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 a7e18eff70ea0d..1e5660bd05d264 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();