BUG=v8:3443
LOG=Y
R=arv@chromium.org, dslomov@chromium.org
Review URL: https://codereview.chromium.org/
613283002
Patch from Caitlin Potter <caitpotter88@gmail.com>.
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24638
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
// 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.
// 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);
assertSame("x3", Symbol.keyFor(symbol3))
}
TestRegistry()
+
+
+function TestGetOwnPropertySymbolsOnPrimitives() {
+ assertEquals(Object.getOwnPropertySymbols(true), []);
+ assertEquals(Object.getOwnPropertySymbols(5000), []);
+ assertEquals(Object.getOwnPropertySymbols("OK"), []);
+}
+TestGetOwnPropertySymbolsOnPrimitives();
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));
}
'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.