diff --git a/src/lookup-inl.h b/src/lookup-inl.h index cdd32f7ed6..06509975ba 100644 --- a/src/lookup-inl.h +++ b/src/lookup-inl.h @@ -20,7 +20,10 @@ JSReceiver* LookupIterator::NextHolder(Map* map) { next->map()->is_hidden_prototype()); if (!check_derived() && - !(check_hidden() && next->map()->is_hidden_prototype())) { + !(check_hidden() && next->map()->is_hidden_prototype()) && + // Always lookup behind the JSGlobalProxy into the JSGlobalObject, even + // when not checking other hidden prototypes. + !(map->IsJSGlobalProxyMap() && next->IsJSGlobalObject())) { return NULL; } diff --git a/src/objects.cc b/src/objects.cc index 70e218b73f..72578713eb 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -12944,11 +12944,11 @@ bool JSArray::WouldChangeReadOnlyLength(Handle array, uint32_t length = 0; CHECK(array->length()->ToArrayIndex(&length)); if (length <= index) { - Isolate* isolate = array->GetIsolate(); - LookupResult lookup(isolate); - Handle length_string = isolate->factory()->length_string(); - array->LookupOwnRealNamedProperty(length_string, &lookup); - return lookup.IsReadOnly(); + LookupIterator it(array, array->GetIsolate()->factory()->length_string(), + LookupIterator::CHECK_PROPERTY); + CHECK(it.IsFound()); + CHECK(it.HasProperty()); + return it.IsReadOnly(); } return false; } @@ -13332,20 +13332,10 @@ MaybeHandle JSObject::GetKeysForIndexedInterceptor( Maybe JSObject::HasRealNamedProperty(Handle object, Handle key) { - Isolate* isolate = object->GetIsolate(); - SealHandleScope shs(isolate); - // Check access rights if needed. - if (object->IsAccessCheckNeeded()) { - if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { - isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); - RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe()); - return maybe(false); - } - } - - LookupResult result(isolate); - object->LookupOwnRealNamedProperty(key, &result); - return maybe(result.IsFound() && !result.IsInterceptor()); + LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK); + Maybe maybe_result = GetPropertyAttributes(&it); + if (!maybe_result.has_value) return Maybe(); + return maybe(it.IsFound()); } @@ -13380,20 +13370,10 @@ Maybe JSObject::HasRealElementProperty(Handle object, Maybe JSObject::HasRealNamedCallbackProperty(Handle object, Handle key) { - Isolate* isolate = object->GetIsolate(); - SealHandleScope shs(isolate); - // Check access rights if needed. - if (object->IsAccessCheckNeeded()) { - if (!isolate->MayNamedAccess(object, key, v8::ACCESS_HAS)) { - isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS); - RETURN_VALUE_IF_SCHEDULED_EXCEPTION(isolate, Maybe()); - return maybe(false); - } - } - - LookupResult result(isolate); - object->LookupOwnRealNamedProperty(key, &result); - return maybe(result.IsPropertyCallbacks()); + LookupIterator it(object, key, LookupIterator::CHECK_ACCESS_CHECK); + Maybe maybe_result = GetPropertyAttributes(&it); + if (!maybe_result.has_value) return Maybe(); + return maybe(it.IsFound() && it.property_kind() == LookupIterator::ACCESSOR); } diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index a89c996f29..48106bc014 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -21771,7 +21771,6 @@ TEST(AccessCheckThrows) { // Create a context and set an x property on it's global object. LocalContext context0(NULL, global_template); - context0->Global()->Set(v8_str("x"), v8_num(42)); v8::Handle global0 = context0->Global(); // Create a context with a different security token so that the