Changes to handling of primitive values as input in some static methods of `Object`

RESOLVED FIXED

Status

()

Core
JavaScript: Standard Library
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: ziyunfei, Unassigned)

Tracking

(Blocks: 1 bug, {dev-doc-complete, meta})

Trunk
dev-doc-complete, meta
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2139.0 Safari/537.36

Steps to reproduce:

The quote from ES6 draft rev27 Annex E:

"19.1.2.5: In Edition 6, if the argument to Object.freeze is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.6: In Edition 6, if the argument to Object.getOwnPropertyDescriptor is not an object an attempt is make to coerce the argument using ToObject. If the coercion is successful the result is used in place of the original argument value. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.7: In Edition 6, if the argument to Object.getOwnPropertyNames is not an object an attempt is make to coerce the argument using ToObject. If the coercion is successful the result is used in place of the original argument value. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.9: In Edition 6, if the argument to Object.getPrototypeOf is not an object an attempt is make to coerce the argument using ToObject. If the coercion is successful the result is used in place of the original argument value. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.11: In Edition 6, if the argument to Object.isExtensible is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.12: In Edition 6, if the argument to Object.isFrozen is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.13: In Edition 6, if the argument to Object.isSealed is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.14: In Edition 6, if the argument to Object.keys is not an object an attempt is make to coerce the argument using ToObject. If the coercion is successful the result is used in place of the original argument value. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.15: In Edition 6, if the argument to Object.preventExtensions is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In Edition 5, a non-object argument always causes a TypeError to be thrown.

19.1.2.17: In Edition 6, if the argument to Object.seal is not an object it is treated as if it was a non-extensible ordinary object with no own properties. In Edition 5, a non-object argument always causes a TypeError to be thrown."


Actual results:

js> Object.freeze("foo")
TypeError: "foo" is not an object      
// should return "foo"

js> Object.getOwnPropertyDescriptor("foo", 0)
TypeError: "foo" is not an object     
// should return {configurable:false, enumerable:true, value:"f", writable:false}

js> Object.getOwnPropertyNames("foo")
["length", "0", "1", "2"]
// this one was fixed in https://bugzilla.mozilla.org/page.cgi?id=splinter.html&bug=645416&attachment=8437119

js> Object.getPrototypeOf("foo")
TypeError: "foo" is not an object
// should return `String.prototype`

js> Object.isExtensible("foo")
TypeError: "foo" is not an object
// should return false

js> Object.isFrozen("foo")
TypeError: "foo" is not an object
// should return true

js> Object.isSealed("foo")
TypeError: "foo" is not an object
// should return true

js> Object.keys("foo")
TypeError: "foo" is not an object
// should return ["0", "1", "2"]

js> Object.preventExtensions("foo")
TypeError: "foo" is not an object
// should return "foo"

js> Object.seal("foo")
TypeError: "foo" is not an object
// should return "foo"
(Reporter)

Updated

3 years ago
Duplicate of this bug: 1038545
Depends on: 1038545
As explained in bug 1038545, let's use this as a meta bug for tracking all these changes. Please file individual bugs blocking this one for each of the issues if you intend to work on them.
Blocks: 694100
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: dev-doc-needed, meta
OS: Mac OS X → All
Hardware: x86 → All
Summary: The backward-incompatible changes of some static methods of `Object` in ES6 → Changes to handling of primitive values as input in some static methods of `Object`
(Reporter)

Updated

3 years ago
Depends on: 1060873
(Reporter)

Updated

3 years ago
Depends on: 1062860
(Reporter)

Updated

3 years ago
Depends on: 1071464
(Reporter)

Updated

3 years ago
Depends on: 1073446
(Reporter)

Updated

3 years ago
Depends on: 1075294
(Reporter)

Updated

3 years ago
Depends on: 1076588
(Reporter)

Updated

3 years ago
Depends on: 1079090
(Reporter)

Updated

3 years ago
Depends on: 1079188
(Reporter)

Updated

3 years ago
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Keywords: dev-doc-needed → dev-doc-complete
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.