Index: src/v8natives.js |
diff --git a/src/v8natives.js b/src/v8natives.js |
index 700b9e47e78f6c4d35f2cfe1c4089970eacf3071..3dcf430b8eeccfab1f6c9739084eb536dd0959bf 100644 |
--- a/src/v8natives.js |
+++ b/src/v8natives.js |
@@ -276,7 +276,7 @@ function ObjectLookupSetter(name) { |
function ObjectKeys(obj) { |
if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
- throw MakeTypeError('object_keys_non_object', [obj]); |
+ throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); |
return %LocalKeys(obj); |
} |
@@ -493,23 +493,59 @@ function DefineOwnProperty(obj, p, desc, should_throw) { |
// ES5 section 15.2.3.2. |
function ObjectGetPrototypeOf(obj) { |
- if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) { |
- throw MakeTypeError("object_get_prototype_non_object", [obj]); |
- } |
- return obj.__proto__; |
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
+ throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]); |
+ return obj.__proto__; |
} |
// ES5 section 15.2.3.3 |
function ObjectGetOwnPropertyDescriptor(obj, p) { |
- if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) { |
- throw MakeTypeError("object_get_prototype_non_object", [obj]); |
- } |
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
+ throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescriptor"]); |
var desc = GetOwnProperty(obj, p); |
return FromPropertyDescriptor(desc); |
} |
+// ES5 section 15.2.3.4. |
+function ObjectGetOwnPropertyNames(obj) { |
+ if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
+ throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"]); |
+ |
+ // Find all the indexed properties. |
+ |
+ // Get the local element names. |
+ var propertyNames = %GetLocalElementNames(obj); |
+ |
+ // Get names for indexed interceptor properties. |
+ if (%GetInterceptorInfo(obj) & 1) { |
+ var indexedInterceptorNames = |
+ %GetIndexedInterceptorElementNames(obj); |
+ if (indexedInterceptorNames) { |
+ propertyNames = propertyNames.concat(indexedInterceptorNames); |
+ } |
+ } |
+ |
+ // Find all the named properties. |
+ |
+ // Get the local property names. |
+ propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj)); |
+ |
+ // Get names for named interceptor properties if any. |
+ |
+ if (%GetInterceptorInfo(obj) & 2) { |
+ var namedInterceptorNames = |
+ %GetNamedInterceptorPropertyNames(obj); |
+ if (namedInterceptorNames) { |
+ propertyNames = propertyNames.concat(namedInterceptorNames); |
+ } |
+ } |
+ |
+ return propertyNames; |
+} |
+ |
+ |
// ES5 section 15.2.3.5. |
function ObjectCreate(proto, properties) { |
if (!IS_OBJECT(proto) && !IS_NULL(proto)) { |
@@ -576,7 +612,8 @@ function SetupObject() { |
"keys", ObjectKeys, |
"create", ObjectCreate, |
"getPrototypeOf", ObjectGetPrototypeOf, |
- "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor |
+ "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
+ "getOwnPropertyNames", ObjectGetOwnPropertyNames |
)); |
} |