Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index 2e3fea2bb4282724e3c630c32374bf0210ecd9ee..f45447c429dca5492d67562e114d2910f30dffcf 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -896,11 +896,23 @@ RUNTIME_FUNCTION(Runtime_GetOwnElementNames) { |
if (!args[0]->IsJSObject()) { |
return isolate->heap()->undefined_value(); |
} |
- CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
+ |
+ // TODO(cbruni): implement proper prototype lookup like in GetOwnPropertyNames |
+ if (object->IsJSGlobalProxy()) { |
+ // All the elements are stored on the globa_object and not directly on the |
+ // global object proxy. |
+ PrototypeIterator iter(isolate, object, |
+ PrototypeIterator::START_AT_PROTOTYPE); |
+ if (iter.IsAtEnd(PrototypeIterator::END_AT_NON_HIDDEN)) { |
+ return *isolate->factory()->NewJSArray(0); |
+ } |
+ object = PrototypeIterator::GetCurrent<JSObject>(iter); |
+ } |
- int n = obj->NumberOfOwnElements(NONE); |
+ int n = object->NumberOfOwnElements(NONE); |
Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); |
- obj->GetOwnElementKeys(*names, NONE); |
+ object->GetOwnElementKeys(*names, NONE); |
return *isolate->factory()->NewJSArrayWithElements(names); |
} |