Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index db4d9b5a0cb544bb43f51a088e57eb69eef520d7..44a5b9e0a23394d8942da8cae6b06987049d4bbe 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -7347,6 +7347,48 @@ 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(); |
|
jochen (gone - plz use gerrit)
2016/09/06 16:02:34
all our API methods are sloppy, i.e., you need to
Franzi
2016/09/06 16:45:37
Done. Thanks!
|
| + |
| + 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. |
| + if (!PropertyDescriptor::ToPropertyDescriptor(isolate, result, desc)) { |
| + return Nothing<bool>(); |
|
jochen (gone - plz use gerrit)
2016/09/06 16:02:34
returning Nothing<> usually implies a pending exce
Franzi
2016/09/06 16:45:37
From what I understand, that's the case. I added a
|
| + } |
| + 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 +7403,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); |