Object.getOwnPropertyNames should return string names for indexed properties
authoryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Feb 2010 10:08:39 +0000 (10:08 +0000)
committeryurys@chromium.org <yurys@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Feb 2010 10:08:39 +0000 (10:08 +0000)
Land original change by pfeldman: http://codereview.chromium.org/596117
Review URL: http://codereview.chromium.org/596124

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3866 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/v8natives.js
test/mjsunit/object-get-own-property-names.js

index 5a47211..6c89715 100644 (file)
@@ -623,9 +623,8 @@ function ObjectGetOwnPropertyNames(obj) {
   if (%GetInterceptorInfo(obj) & 1) {
     var indexedInterceptorNames =
         %GetIndexedInterceptorElementNames(obj);
-    if (indexedInterceptorNames) {
+    if (indexedInterceptorNames)
       propertyNames = propertyNames.concat(indexedInterceptorNames);
-    }
   }
 
   // Find all the named properties.
@@ -643,6 +642,10 @@ function ObjectGetOwnPropertyNames(obj) {
     }
   }
 
+  // Property names are expected to be strings.
+  for (var i = 0; i < propertyNames.length; ++i)
+    propertyNames[i] = ToString(propertyNames[i]);
+
   return propertyNames;
 }
 
index f52cee2..33aa85e 100644 (file)
@@ -57,6 +57,8 @@ propertyNames.sort();
 assertEquals(3, propertyNames.length);
 assertEquals("0", propertyNames[0]);
 assertEquals("1", propertyNames[1]);
+assertEquals("string", typeof propertyNames[0]);
+assertEquals("string", typeof propertyNames[1]);
 assertEquals("length", propertyNames[2]);
 
 // Check that no proto properties are returned.