[ES6] Object type restrictions on a first parameter of several Object.* functions...
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2015 17:44:37 +0000 (17:44 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 31 Mar 2015 17:44:37 +0000 (17:44 +0000)
commit004e5bfdc20a99dd1db8b1becd6777881795bdc3
tree84243637fc69db54205fc4fd94f2dcae466d2353
parent36990d04a9c59180fa4e16b98f9112eb7b99c3a2
[ES6] Object type restrictions on a first parameter of several Object.* functions are relaxed
https://bugs.webkit.org/show_bug.cgi?id=142937

Reviewed by Darin Adler.

Source/JavaScriptCore:

In ES6, Object type restrictions on a first parameter of several Object.* functions are relaxed.
In ES5 or prior, when a first parameter is not object type, these functions raise TypeError.
But now, several functions perform ToObject onto a non-object parameter.
And others behaves as if a parameter is a non-extensible ordinary object with no own properties.
It is described in ES6 Annex E.
Functions different from ES5 are following.

1. An attempt is make to coerce the argument using ToObject.
    Object.getOwnPropertyDescriptor
    Object.getOwnPropertyNames
    Object.getPrototypeOf
    Object.keys

2. Treated as if it was a non-extensible ordinary object with no own properties.
    Object.freeze
    Object.isExtensible
    Object.isFrozen
    Object.isSealed
    Object.preventExtensions
    Object.seal

* runtime/ObjectConstructor.cpp:
(JSC::ObjectConstructorGetPrototypeOfFunctor::operator()):
(JSC::objectConstructorGetPrototypeOf):
(JSC::objectConstructorGetOwnPropertyDescriptor):
(JSC::objectConstructorGetOwnPropertyNames):
(JSC::objectConstructorKeys):
(JSC::objectConstructorSeal):
(JSC::objectConstructorFreeze):
(JSC::objectConstructorPreventExtensions):
(JSC::objectConstructorIsSealed):
(JSC::objectConstructorIsFrozen):
(JSC::objectConstructorIsExtensible):
* tests/stress/object-freeze-accept-non-object.js: Added.
* tests/stress/object-get-own-property-descriptor-perform-to-object.js: Added.
(canary):
* tests/stress/object-get-own-property-names-perform-to-object.js: Added.
(compare):
* tests/stress/object-get-prototype-of-perform-to-object.js: Added.
* tests/stress/object-is-extensible-accept-non-object.js: Added.
* tests/stress/object-is-frozen-accept-non-object.js: Added.
* tests/stress/object-is-sealed-accept-non-object.js: Added.
* tests/stress/object-keys-perform-to-object.js: Added.
(compare):
* tests/stress/object-prevent-extensions-accept-non-object.js: Added.
* tests/stress/object-seal-accept-non-object.js: Added.

LayoutTests:

Several LayoutTests are updated with the new behavior.
Test cases in IETestCenter contain test for the outdated behavior.
But IETestCenter is brought from the external source, so instead of modifying it,
we mark them as Failure in TestExpectations.

* TestExpectations:
* js/dom/getOwnPropertyDescriptor-expected.txt:
* js/prototypes-expected.txt:
* js/resources/getOwnPropertyDescriptor.js:
* js/script-tests/prototypes.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182189 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/js/dom/getOwnPropertyDescriptor-expected.txt
LayoutTests/js/prototypes-expected.txt
LayoutTests/js/resources/getOwnPropertyDescriptor.js
LayoutTests/js/script-tests/prototypes.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ObjectConstructor.cpp
Source/JavaScriptCore/tests/stress/object-freeze-accept-non-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-get-own-property-descriptor-perform-to-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-get-own-property-names-perform-to-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-get-prototype-of-perform-to-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-is-extensible-accept-non-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-is-frozen-accept-non-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-is-sealed-accept-non-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-keys-perform-to-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-prevent-extensions-accept-non-object.js [new file with mode: 0644]
Source/JavaScriptCore/tests/stress/object-seal-accept-non-object.js [new file with mode: 0644]