Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 7b8f506d4690720b936adeb50d7debfce0811b88..051bc0f36bdc2ef257eb0de1a4299f839e7d6729 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -7347,6 +7347,57 @@ Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(Isolate* isolate, |
return GetOwnPropertyDescriptor(&it, desc); |
} |
+namespace { |
+ |
+Maybe<bool> GetPropertyDescriptorWithInterceptor(LookupIterator* it, |
+ PropertyDescriptor* desc) { |
+ if (it->state() == LookupIterator::INTERCEPTOR) { |
+ Isolate* isolate = it->isolate(); |
+ Handle<InterceptorInfo> interceptor = it->GetInterceptor(); |
+ if (!interceptor->descriptor()->IsUndefined(isolate)) { |
+ Handle<Object> result; |
+ Handle<JSObject> holder = it->GetHolder<JSObject>(); |
+ |
+ Handle<Object> receiver = it->GetReceiver(); |
+ if (!receiver->IsJSReceiver()) { |
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
+ isolate, receiver, Object::ConvertReceiver(isolate, receiver), |
+ Nothing<bool>()); |
+ } |
+ |
+ PropertyCallbackArguments args(isolate, interceptor->data(), *receiver, |
+ *holder, Object::DONT_THROW); |
+ if (it->IsElement()) { |
+ uint32_t index = it->index(); |
+ v8::IndexedPropertyDescriptorCallback descriptorCallback = |
+ v8::ToCData<v8::IndexedPropertyDescriptorCallback>( |
+ interceptor->descriptor()); |
+ |
+ result = args.Call(descriptorCallback, index); |
+ } else { |
+ Handle<Name> name = it->name(); |
+ DCHECK(!name->IsPrivate()); |
+ v8::GenericNamedPropertyDescriptorCallback descriptorCallback = |
+ v8::ToCData<v8::GenericNamedPropertyDescriptorCallback>( |
+ interceptor->descriptor()); |
+ result = args.Call(descriptorCallback, name); |
+ } |
+ if (!result.is_null()) { |
+ // Request successfully intercepted, try to set the property |
+ // descriptor. |
+ Utils::ApiCheck( |
+ PropertyDescriptor::ToPropertyDescriptor(isolate, result, desc), |
+ it->IsElement() ? "v8::IndexedPropertyDescriptorCallback" |
+ : "v8::NamedPropertyDescriptorCallback", |
+ "Invalid property descriptor."); |
+ |
+ return Just(true); |
+ } |
+ } |
+ } |
+ return Just(false); |
+} |
+} // namespace |
// ES6 9.1.5.1 |
// Returns true on success, false if the property didn't exist, nothing if |
@@ -7361,6 +7412,13 @@ Maybe<bool> JSReceiver::GetOwnPropertyDescriptor(LookupIterator* it, |
it->GetName(), desc); |
} |
+ Maybe<bool> intercepted = GetPropertyDescriptorWithInterceptor(it, desc); |
+ MAYBE_RETURN(intercepted, Nothing<bool>()); |
+ if (intercepted.FromJust()) { |
+ return Just(true); |
+ } |
+ |
+ // Request was not intercepted, continue as normal. |
// 1. (Assert) |
// 2. If O does not have an own property with key P, return undefined. |
Maybe<PropertyAttributes> maybe = JSObject::GetPropertyAttributes(it); |