Browse Source

Revert "v8: drop v8::FunctionCallbackInfo<T>::NewTarget()"

See the commit log of the reverted commit: it's a semver-minor change
that can land in the next minor release.

This reverts commit 47cbb88ac5929ce6ba17f681785034dd019ce063.
v6.x
Ben Noordhuis 8 years ago
committed by Myles Borins
parent
commit
2b3381aec6
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 7
      deps/v8/include/v8.h
  2. 37
      deps/v8/test/cctest/test-api.cc

7
deps/v8/include/v8.h

@ -3177,6 +3177,7 @@ class FunctionCallbackInfo {
Local<Function> Callee() const); Local<Function> Callee() const);
V8_INLINE Local<Object> This() const; V8_INLINE Local<Object> This() const;
V8_INLINE Local<Object> Holder() const; V8_INLINE Local<Object> Holder() const;
V8_INLINE Local<Value> NewTarget() const;
V8_INLINE bool IsConstructCall() const; V8_INLINE bool IsConstructCall() const;
V8_INLINE Local<Value> Data() const; V8_INLINE Local<Value> Data() const;
V8_INLINE Isolate* GetIsolate() const; V8_INLINE Isolate* GetIsolate() const;
@ -7903,6 +7904,12 @@ Local<Object> FunctionCallbackInfo<T>::Holder() const {
&implicit_args_[kHolderIndex])); &implicit_args_[kHolderIndex]));
} }
template<typename T>
Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
return Local<Value>(
reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex]));
}
template<typename T> template<typename T>
Local<Value> FunctionCallbackInfo<T>::Data() const { Local<Value> FunctionCallbackInfo<T>::Data() const {
return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]));

37
deps/v8/test/cctest/test-api.cc

@ -13350,6 +13350,43 @@ THREADED_TEST(IsConstructCall) {
CHECK(value->BooleanValue(context.local()).FromJust()); CHECK(value->BooleanValue(context.local()).FromJust());
} }
static void NewTargetHandler(const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
args.GetReturnValue().Set(args.NewTarget());
}
THREADED_TEST(NewTargetHandler) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
// Function template with call handler.
Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
templ->SetCallHandler(NewTargetHandler);
LocalContext context;
Local<Function> function =
templ->GetFunction(context.local()).ToLocalChecked();
CHECK(context->Global()
->Set(context.local(), v8_str("f"), function)
.FromJust());
Local<Value> value = CompileRun("f()");
CHECK(value->IsUndefined());
value = CompileRun("new f()");
CHECK(value->IsFunction());
CHECK(value == function);
Local<Value> subclass = CompileRun("var g = class extends f { }; g");
CHECK(subclass->IsFunction());
value = CompileRun("new g()");
CHECK(value->IsFunction());
CHECK(value == subclass);
value = CompileRun("Reflect.construct(f, [], Array)");
CHECK(value->IsFunction());
CHECK(value ==
context->Global()
->Get(context.local(), v8_str("Array"))
.ToLocalChecked());
}
THREADED_TEST(ObjectProtoToString) { THREADED_TEST(ObjectProtoToString) {
v8::Isolate* isolate = CcTest::isolate(); v8::Isolate* isolate = CcTest::isolate();

Loading…
Cancel
Save