Also handle elements in *RealNamed* api methods
Apparently the *RealNamed* API methods only have named variants, but were always used by the embedder to find elements as well. We'd never find them though, since we wouldn't even look there. This CL ensures we check whether the name is actually an array index. I guess for all named API functions we should assume they are used similar to o["name"] where name could also be a number... At least we should make it uniform between embedder and V8. This matches us up with their expectations for now... BUG=v8:4137 LOG=n Review URL: https://codereview.chromium.org/1177383004 Cr-Commit-Position: refs/heads/master@{#29008}
This commit is contained in:
parent
a6bc7cd4e2
commit
028025f07e
20
src/api.cc
20
src/api.cc
@ -4223,8 +4223,9 @@ MaybeLocal<Value> v8::Object::GetRealNamedPropertyInPrototypeChain(
|
||||
i::PrototypeIterator iter(isolate, self);
|
||||
if (iter.IsAtEnd()) return MaybeLocal<Value>();
|
||||
auto proto = i::PrototypeIterator::GetCurrent(iter);
|
||||
i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
i::LookupIterator it = i::LookupIterator::PropertyOrElement(
|
||||
isolate, self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
Local<Value> result;
|
||||
has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
|
||||
RETURN_ON_FAILED_EXECUTION(Value);
|
||||
@ -4252,8 +4253,9 @@ v8::Object::GetRealNamedPropertyAttributesInPrototypeChain(
|
||||
i::PrototypeIterator iter(isolate, self);
|
||||
if (iter.IsAtEnd()) return Nothing<PropertyAttribute>();
|
||||
auto proto = i::PrototypeIterator::GetCurrent(iter);
|
||||
i::LookupIterator it(self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
i::LookupIterator it = i::LookupIterator::PropertyOrElement(
|
||||
isolate, self, key_obj, i::Handle<i::JSReceiver>::cast(proto),
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
auto result = i::JSReceiver::GetPropertyAttributes(&it);
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
|
||||
if (!it.IsFound()) return Nothing<PropertyAttribute>();
|
||||
@ -4277,8 +4279,9 @@ MaybeLocal<Value> v8::Object::GetRealNamedProperty(Local<Context> context,
|
||||
PREPARE_FOR_EXECUTION(context, "v8::Object::GetRealNamedProperty()", Value);
|
||||
auto self = Utils::OpenHandle(this);
|
||||
auto key_obj = Utils::OpenHandle(*key);
|
||||
i::LookupIterator it(self, key_obj,
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
i::LookupIterator it = i::LookupIterator::PropertyOrElement(
|
||||
isolate, self, key_obj,
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
Local<Value> result;
|
||||
has_pending_exception = !ToLocal<Value>(i::Object::GetProperty(&it), &result);
|
||||
RETURN_ON_FAILED_EXECUTION(Value);
|
||||
@ -4300,8 +4303,9 @@ Maybe<PropertyAttribute> v8::Object::GetRealNamedPropertyAttributes(
|
||||
PropertyAttribute);
|
||||
auto self = Utils::OpenHandle(this);
|
||||
auto key_obj = Utils::OpenHandle(*key);
|
||||
i::LookupIterator it(self, key_obj,
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
i::LookupIterator it = i::LookupIterator::PropertyOrElement(
|
||||
isolate, self, key_obj,
|
||||
i::LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
|
||||
auto result = i::JSReceiver::GetPropertyAttributes(&it);
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(PropertyAttribute);
|
||||
if (!it.IsFound()) return Nothing<PropertyAttribute>();
|
||||
|
@ -13403,7 +13403,8 @@ MaybeHandle<JSObject> JSObject::GetKeysForIndexedInterceptor(
|
||||
|
||||
Maybe<bool> JSObject::HasRealNamedProperty(Handle<JSObject> object,
|
||||
Handle<Name> name) {
|
||||
LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
LookupIterator it = LookupIterator::PropertyOrElement(
|
||||
name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
|
||||
if (!maybe_result.IsJust()) return Nothing<bool>();
|
||||
return Just(it.IsFound());
|
||||
@ -13423,7 +13424,8 @@ Maybe<bool> JSObject::HasRealElementProperty(Handle<JSObject> object,
|
||||
|
||||
Maybe<bool> JSObject::HasRealNamedCallbackProperty(Handle<JSObject> object,
|
||||
Handle<Name> name) {
|
||||
LookupIterator it(object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
LookupIterator it = LookupIterator::PropertyOrElement(
|
||||
name->GetIsolate(), object, name, LookupIterator::OWN_SKIP_INTERCEPTOR);
|
||||
Maybe<PropertyAttributes> maybe_result = GetPropertyAttributes(&it);
|
||||
return maybe_result.IsJust() ? Just(it.state() == LookupIterator::ACCESSOR)
|
||||
: Nothing<bool>();
|
||||
|
Loading…
Reference in New Issue
Block a user