Reviewers: ,

Message:
Quick patch to match Harmony semantics for ObjectKeys(O)
(https://code.google.com/p/v8/issues/detail?id=3587)

Description:
Convert `obj` ToObject in Object.keys()

BUG=v8:3587

Please review this at https://codereview.chromium.org/585373003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+3, -5 lines):
  M src/v8natives.js
  M test/mjsunit/third_party/object-keys.js


Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 405e7d6790932b66b473ff83478f504363ca7894..9da6a2f61ec5613030efc925ff0da37005e09598 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -325,9 +325,7 @@ function ObjectLookupSetter(name) {


 function ObjectKeys(obj) {
-  if (!IS_SPEC_OBJECT(obj)) {
-    throw MakeTypeError("called_on_non_object", ["Object.keys"]);
-  }
+  obj = ToObject(obj);
   if (%IsJSProxy(obj)) {
     var handler = %GetHandler(obj);
     var names = CallTrap0(handler, "keys", DerivedKeysTrap);
Index: test/mjsunit/third_party/object-keys.js
diff --git a/test/mjsunit/third_party/object-keys.js b/test/mjsunit/third_party/object-keys.js index d09265c6f738a3729bd8b75ad80a1b304408e6c9..c8003745c4b1c5ccfb4b2b04e0f9eca72594f3f7 100644
--- a/test/mjsunit/third_party/object-keys.js
+++ b/test/mjsunit/third_party/object-keys.js
@@ -31,8 +31,8 @@

 // Based on LayoutTests/fast/js/Object-keys.html

-assertThrows(function () { Object.keys(2) }, TypeError);
-assertThrows(function () { Object.keys("foo") }, TypeError);
+assertEquals(Object.keys(2), []);
+assertEquals(Object.keys("foo"), ["0", "1", "2"]);
 assertThrows(function () { Object.keys(null) }, TypeError);
 assertThrows(function () { Object.keys(undefined) }, TypeError);



--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to