diff --git a/src/objects.cc b/src/objects.cc index 6db8e9963e..69727d25e3 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -6679,6 +6679,13 @@ JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) { return UNDEFINED_ELEMENT; } + if (IsJSGlobalProxy()) { + Object* proto = GetPrototype(); + if (proto->IsNull()) return UNDEFINED_ELEMENT; + ASSERT(proto->IsJSGlobalObject()); + return JSObject::cast(proto)->HasLocalElement(index); + } + // Check for lookup interceptor if (HasIndexedInterceptor()) { return HasElementWithInterceptor(this, index) ? INTERCEPTED_ELEMENT diff --git a/src/runtime.cc b/src/runtime.cc index 5791b72850..6b0ca69b3b 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -779,6 +779,12 @@ static MaybeObject* Runtime_GetOwnProperty(Arguments args) { } case JSObject::DICTIONARY_ELEMENT: { + if (obj->IsJSGlobalProxy()) { + Object* proto = obj->GetPrototype(); + if (proto->IsNull()) return Heap::undefined_value(); + ASSERT(proto->IsJSGlobalObject()); + obj = Handle(JSObject::cast(proto)); + } NumberDictionary* dictionary = obj->element_dictionary(); int entry = dictionary->FindEntry(index); ASSERT(entry != NumberDictionary::kNotFound); diff --git a/test/mjsunit/get-own-property-descriptor.js b/test/mjsunit/get-own-property-descriptor.js index ceb7715384..79c1fac6ae 100644 --- a/test/mjsunit/get-own-property-descriptor.js +++ b/test/mjsunit/get-own-property-descriptor.js @@ -103,3 +103,19 @@ objWithProto.prototype = proto; objWithProto[0] = 'bar'; var descWithProto = Object.getOwnPropertyDescriptor(objWithProto, '10'); assertEquals(undefined, descWithProto); + +// Test elements on global proxy object. +var global = (function() { return this; })(); + +global[42] = 42; + +function el_getter() { return 239; }; +function el_setter() {}; +Object.defineProperty(global, '239', {get: el_getter, set: el_setter}); + +var descRegularElement = Object.getOwnPropertyDescriptor(global, '42'); +assertEquals(42, descRegularElement.value); + +var descAccessorElement = Object.getOwnPropertyDescriptor(global, '239'); +assertEquals(el_getter, descAccessorElement.get); +assertEquals(el_setter, descAccessorElement.set);