Revision: 24638
Author: [email protected]
Date: Wed Oct 15 14:01:20 2014 UTC
Log: Convert argument toObject() in
Object.getOwnPropertyNames/Descriptors
BUG=v8:3443
LOG=Y
[email protected], [email protected]
Review URL: https://codereview.chromium.org/613283002
Patch from Caitlin Potter <[email protected]>.
https://code.google.com/p/v8/source/detail?r=24638
Modified:
/branches/bleeding_edge/src/symbol.js
/branches/bleeding_edge/src/v8natives.js
/branches/bleeding_edge/test/mjsunit/es6/symbols.js
/branches/bleeding_edge/test/mjsunit/object-get-own-property-names.js
/branches/bleeding_edge/test/test262/test262.status
=======================================
--- /branches/bleeding_edge/src/symbol.js Fri Aug 8 11:42:59 2014 UTC
+++ /branches/bleeding_edge/src/symbol.js Wed Oct 15 14:01:20 2014 UTC
@@ -69,10 +69,7 @@
// ES6 19.1.2.8
function ObjectGetOwnPropertySymbols(obj) {
- if (!IS_SPEC_OBJECT(obj)) {
- throw MakeTypeError("called_on_non_object",
- ["Object.getOwnPropertySymbols"]);
- }
+ obj = ToObject(obj);
// TODO(arv): Proxies use a shared trap for String and Symbol keys.
=======================================
--- /branches/bleeding_edge/src/v8natives.js Wed Oct 15 13:26:43 2014 UTC
+++ /branches/bleeding_edge/src/v8natives.js Wed Oct 15 14:01:20 2014 UTC
@@ -1107,9 +1107,7 @@
// ES5 section 15.2.3.4.
function ObjectGetOwnPropertyNames(obj) {
- if (!IS_SPEC_OBJECT(obj)) {
- throw MakeTypeError("called_on_non_object",
["Object.getOwnPropertyNames"]);
- }
+ obj = ToObject(obj);
// Special handling for proxies.
if (%_IsJSProxy(obj)) {
var handler = %GetHandler(obj);
=======================================
--- /branches/bleeding_edge/test/mjsunit/es6/symbols.js Fri Sep 12 16:17:27
2014 UTC
+++ /branches/bleeding_edge/test/mjsunit/es6/symbols.js Wed Oct 15 14:01:20
2014 UTC
@@ -501,3 +501,11 @@
assertSame("x3", Symbol.keyFor(symbol3))
}
TestRegistry()
+
+
+function TestGetOwnPropertySymbolsOnPrimitives() {
+ assertEquals(Object.getOwnPropertySymbols(true), []);
+ assertEquals(Object.getOwnPropertySymbols(5000), []);
+ assertEquals(Object.getOwnPropertySymbols("OK"), []);
+}
+TestGetOwnPropertySymbolsOnPrimitives();
=======================================
--- /branches/bleeding_edge/test/mjsunit/object-get-own-property-names.js
Tue Mar 12 20:15:03 2013 UTC
+++ /branches/bleeding_edge/test/mjsunit/object-get-own-property-names.js
Wed Oct 15 14:01:20 2014 UTC
@@ -87,30 +87,20 @@
assertSame(Array.prototype, propertyNames.__proto__);
Array.prototype.concat = savedConcat;
-try {
- Object.getOwnPropertyNames(4);
- assertTrue(false);
-} catch (e) {
- assertTrue(/on non-object/.test(e));
-}
-
-try {
- Object.getOwnPropertyNames("foo");
- assertTrue(false);
-} catch (e) {
- assertTrue(/on non-object/.test(e));
-}
+assertEquals(Object.getOwnPropertyNames(4), []);
+assertEquals(Object.getOwnPropertyNames("foo"), ["0", "1", "2", "length"]);
+assertEquals(Object.getOwnPropertyNames(true), []);
try {
Object.getOwnPropertyNames(undefined);
assertTrue(false);
} catch (e) {
- assertTrue(/on non-object/.test(e));
+ assertTrue(/Cannot convert undefined or null to object/.test(e));
}
try {
Object.getOwnPropertyNames(null);
assertTrue(false);
} catch (e) {
- assertTrue(/on non-object/.test(e));
+ assertTrue(/Cannot convert undefined or null to object/.test(e));
}
=======================================
--- /branches/bleeding_edge/test/test262/test262.status Mon Oct 13 11:11:15
2014 UTC
+++ /branches/bleeding_edge/test/test262/test262.status Wed Oct 15 14:01:20
2014 UTC
@@ -93,6 +93,11 @@
'15.2.3.14-1-2': [FAIL_OK],
'15.2.3.14-1-3': [FAIL_OK],
+ # Object.getOwnPropertyNames(O) no longer throws when passed a primitive
value.
+ '15.2.3.4-1-4': [FAIL_OK],
+ '15.2.3.4-1-5': [FAIL_OK],
+ '15.2.3.4-1': [FAIL_OK],
+
############################ SKIPPED TESTS #############################
# These tests take a looong time to run in debug mode.
--
--
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.