Commit 2fd8a7f6 authored by dslomov@chromium.org's avatar dslomov@chromium.org

Convert `obj` ToObject in Object.keys()

BUG=v8:3587
LOG=Y
R=arv@chromium.org, dslomov@chromium.org

Review URL: https://codereview.chromium.org/585373003

Patch from Caitlin Potter <caitpotter88@gmail.com>.

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24495 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2cdb96d7
...@@ -27,6 +27,7 @@ Andreas Anyuru <andreas.anyuru@gmail.com> ...@@ -27,6 +27,7 @@ Andreas Anyuru <andreas.anyuru@gmail.com>
Baptiste Afsa <baptiste.afsa@arm.com> Baptiste Afsa <baptiste.afsa@arm.com>
Bert Belder <bertbelder@gmail.com> Bert Belder <bertbelder@gmail.com>
Burcu Dogan <burcujdogan@gmail.com> Burcu Dogan <burcujdogan@gmail.com>
Caitlin Potter <caitpotter88@gmail.com>
Craig Schlenter <craig.schlenter@gmail.com> Craig Schlenter <craig.schlenter@gmail.com>
Chunyang Dai <chunyang.dai@intel.com> Chunyang Dai <chunyang.dai@intel.com>
Daniel Andersson <kodandersson@gmail.com> Daniel Andersson <kodandersson@gmail.com>
......
...@@ -325,9 +325,7 @@ function ObjectLookupSetter(name) { ...@@ -325,9 +325,7 @@ function ObjectLookupSetter(name) {
function ObjectKeys(obj) { function ObjectKeys(obj) {
if (!IS_SPEC_OBJECT(obj)) { obj = ToObject(obj);
throw MakeTypeError("called_on_non_object", ["Object.keys"]);
}
if (%IsJSProxy(obj)) { if (%IsJSProxy(obj)) {
var handler = %GetHandler(obj); var handler = %GetHandler(obj);
var names = CallTrap0(handler, "keys", DerivedKeysTrap); var names = CallTrap0(handler, "keys", DerivedKeysTrap);
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
// Based on LayoutTests/fast/js/Object-keys.html // Based on LayoutTests/fast/js/Object-keys.html
assertThrows(function () { Object.keys(2) }, TypeError); assertEquals(Object.keys(2), []);
assertThrows(function () { Object.keys("foo") }, TypeError); assertEquals(Object.keys("foo"), ["0", "1", "2"]);
assertThrows(function () { Object.keys(null) }, TypeError); assertThrows(function () { Object.keys(null) }, TypeError);
assertThrows(function () { Object.keys(undefined) }, TypeError); assertThrows(function () { Object.keys(undefined) }, TypeError);
......
...@@ -87,6 +87,12 @@ ...@@ -87,6 +87,12 @@
'S15.9.3.1_A5_T5': [PASS, FAIL_OK], 'S15.9.3.1_A5_T5': [PASS, FAIL_OK],
'S15.9.3.1_A5_T6': [PASS, FAIL_OK], 'S15.9.3.1_A5_T6': [PASS, FAIL_OK],
# ObjectKeys() no longer throws TypeError when passed a primitive value which
# is not null or undefined (per ES6).
'15.2.3.14-1-1': [SKIP],
'15.2.3.14-1-2': [SKIP],
'15.2.3.14-1-3': [SKIP],
############################ SKIPPED TESTS ############################# ############################ SKIPPED TESTS #############################
# These tests take a looong time to run in debug mode. # These tests take a looong time to run in debug mode.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment