haikuwebkit/LayoutTests/js/non-strict-function-propert...

30 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
Test caller and arguments properties in function in non strict mode
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Partly implement Function.prototype.{caller,arguments} reflection proposal https://bugs.webkit.org/show_bug.cgi?id=158116 Reviewed by Yusuke Suzuki. JSTests: * ChakraCore/test/strict/19.function.baseline: * ChakraCore/test/strict/22.callerCalleeArguments.baseline-jsc: * microbenchmarks/function-prototype-get.js: Added. * microbenchmarks/reflect-own-keys-function.js: Added. * stress/for-in-shadow-non-enumerable.js: * stress/function-hidden-as-caller.js: * stress/has-own-property-arguments.js: * stress/object-assign-fast-path.js: * stress/put-to-proto-chain-overrides-put.js: * stress/reflect-set.js: * test262/config.yaml: Skip 3 test cases that are now incorrect. * test262/expectations.yaml: Mark 2 test cases as passing. Source/JavaScriptCore: To ensure web-compatibility, only the safe subset of Function.prototype.{caller,arguments} reflection proposal [1] is implemented, which is currently shipped in SpiderMonkey. Complete list of differences from the proposed spec: 1. Cross-realm receiver function is allowed instead of throwing a TypeError. Throwing is likely safe to ship, but #225997 needs to be fixed first for custom properties to receive correct global object. 2. Cross-realm caller function is returned instead of `null`. Hiding cross-realm caller may break things: we currently have a test for the opposite behavior. 3. Defines "caller" and "arguments" setters that throw for disallowed receivers, instead failing silently in sloppy mode. This is actually more restrictive than the spec, which is preferable, and aligns with V8 and SM. Most importantly, this patch removes own "caller" and "arguments" properties from sloppy mode ES5 functions. They were non-configurable, making it harder to use their holder as a [[ProxyTarget]]. They were also non-writable, with a constantly changing [[Value]], which violated the invariants of internal methods [2]. As a result, JSFunction methods are greatly simplified, especially defineOwnProperty() and getOwnSpecialPropertyNames(). The latter is now 2.1x faster according to the provided microbenchmark. Also, removes double "prototype" lookup from [[Get]], which is a 10% progression. [1]: https://github.com/claudepache/es-legacy-function-reflection [2]: https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/FunctionExecutable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::addFunctionProperties): (JSC::isAllowedReceiverFunctionForCallerAndArguments): (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor): (JSC::RetrieveArgumentsFunctor::result const): (JSC::RetrieveArgumentsFunctor::operator() const): (JSC::retrieveArguments): (JSC::JSC_DEFINE_CUSTOM_GETTER): (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): (JSC::RetrieveCallerFunctionFunctor::result const): (JSC::RetrieveCallerFunctionFunctor::operator() const): (JSC::retrieveCallerFunction): (JSC::JSC_DEFINE_CUSTOM_SETTER): (JSC::FunctionPrototype::initRestrictedProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnSpecialPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor): Deleted. (JSC::RetrieveArgumentsFunctor::result const): Deleted. (JSC::RetrieveArgumentsFunctor::operator() const): Deleted. (JSC::retrieveArguments): Deleted. (JSC::JSC_DEFINE_CUSTOM_GETTER): Deleted. (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): Deleted. (JSC::RetrieveCallerFunctionFunctor::result const): Deleted. (JSC::RetrieveCallerFunctionFunctor::operator() const): Deleted. (JSC::retrieveCallerFunction): Deleted. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildrenImpl): * runtime/JSGlobalObject.h: Remove unused m_throwTypeErrorGetterSetter and make [[ThrowTypeError]] lazily-created. * runtime/JSGlobalObjectFunctions.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/JSGlobalObjectFunctions.h: * runtime/JSObject.cpp: (JSC::JSObject::putDirectCustomGetterSetterWithoutTransition): * runtime/JSObject.h: LayoutTests: * inspector/model/remote-object-get-properties-expected.txt: * inspector/runtime/getDisplayableProperties-expected.txt: * inspector/runtime/getProperties-expected.txt: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/kde/function_arguments-expected.txt: * js/kde/script-tests/function_arguments.js: * js/non-strict-function-properties-expected.txt: * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/non-strict-function-properties.js: * js/script-tests/throw-type-error-is-unique.js: Canonical link: https://commits.webkit.org/239947@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-25 22:32:20 +00:00
PASS Object.getOwnPropertyNames(function () {}).length is 3
PASS Object.getOwnPropertyNames(function () {}).includes("caller") is false
PASS Object.getOwnPropertyNames(function () {}).includes("arguments") is false
PASS (function(){}).hasOwnProperty("caller") is false
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS (function(){}).__proto__.hasOwnProperty("caller") is true
Partly implement Function.prototype.{caller,arguments} reflection proposal https://bugs.webkit.org/show_bug.cgi?id=158116 Reviewed by Yusuke Suzuki. JSTests: * ChakraCore/test/strict/19.function.baseline: * ChakraCore/test/strict/22.callerCalleeArguments.baseline-jsc: * microbenchmarks/function-prototype-get.js: Added. * microbenchmarks/reflect-own-keys-function.js: Added. * stress/for-in-shadow-non-enumerable.js: * stress/function-hidden-as-caller.js: * stress/has-own-property-arguments.js: * stress/object-assign-fast-path.js: * stress/put-to-proto-chain-overrides-put.js: * stress/reflect-set.js: * test262/config.yaml: Skip 3 test cases that are now incorrect. * test262/expectations.yaml: Mark 2 test cases as passing. Source/JavaScriptCore: To ensure web-compatibility, only the safe subset of Function.prototype.{caller,arguments} reflection proposal [1] is implemented, which is currently shipped in SpiderMonkey. Complete list of differences from the proposed spec: 1. Cross-realm receiver function is allowed instead of throwing a TypeError. Throwing is likely safe to ship, but #225997 needs to be fixed first for custom properties to receive correct global object. 2. Cross-realm caller function is returned instead of `null`. Hiding cross-realm caller may break things: we currently have a test for the opposite behavior. 3. Defines "caller" and "arguments" setters that throw for disallowed receivers, instead failing silently in sloppy mode. This is actually more restrictive than the spec, which is preferable, and aligns with V8 and SM. Most importantly, this patch removes own "caller" and "arguments" properties from sloppy mode ES5 functions. They were non-configurable, making it harder to use their holder as a [[ProxyTarget]]. They were also non-writable, with a constantly changing [[Value]], which violated the invariants of internal methods [2]. As a result, JSFunction methods are greatly simplified, especially defineOwnProperty() and getOwnSpecialPropertyNames(). The latter is now 2.1x faster according to the provided microbenchmark. Also, removes double "prototype" lookup from [[Get]], which is a 10% progression. [1]: https://github.com/claudepache/es-legacy-function-reflection [2]: https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/FunctionExecutable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::addFunctionProperties): (JSC::isAllowedReceiverFunctionForCallerAndArguments): (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor): (JSC::RetrieveArgumentsFunctor::result const): (JSC::RetrieveArgumentsFunctor::operator() const): (JSC::retrieveArguments): (JSC::JSC_DEFINE_CUSTOM_GETTER): (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): (JSC::RetrieveCallerFunctionFunctor::result const): (JSC::RetrieveCallerFunctionFunctor::operator() const): (JSC::retrieveCallerFunction): (JSC::JSC_DEFINE_CUSTOM_SETTER): (JSC::FunctionPrototype::initRestrictedProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnSpecialPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor): Deleted. (JSC::RetrieveArgumentsFunctor::result const): Deleted. (JSC::RetrieveArgumentsFunctor::operator() const): Deleted. (JSC::retrieveArguments): Deleted. (JSC::JSC_DEFINE_CUSTOM_GETTER): Deleted. (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): Deleted. (JSC::RetrieveCallerFunctionFunctor::result const): Deleted. (JSC::RetrieveCallerFunctionFunctor::operator() const): Deleted. (JSC::retrieveCallerFunction): Deleted. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildrenImpl): * runtime/JSGlobalObject.h: Remove unused m_throwTypeErrorGetterSetter and make [[ThrowTypeError]] lazily-created. * runtime/JSGlobalObjectFunctions.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/JSGlobalObjectFunctions.h: * runtime/JSObject.cpp: (JSC::JSObject::putDirectCustomGetterSetterWithoutTransition): * runtime/JSObject.h: LayoutTests: * inspector/model/remote-object-get-properties-expected.txt: * inspector/runtime/getDisplayableProperties-expected.txt: * inspector/runtime/getProperties-expected.txt: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/kde/function_arguments-expected.txt: * js/kde/script-tests/function_arguments.js: * js/non-strict-function-properties-expected.txt: * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/non-strict-function-properties.js: * js/script-tests/throw-type-error-is-unique.js: Canonical link: https://commits.webkit.org/239947@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-25 22:32:20 +00:00
PASS (function(){}).hasOwnProperty("arguments") is false
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS (function(){}).__proto__.hasOwnProperty("arguments") is true
Partly implement Function.prototype.{caller,arguments} reflection proposal https://bugs.webkit.org/show_bug.cgi?id=158116 Reviewed by Yusuke Suzuki. JSTests: * ChakraCore/test/strict/19.function.baseline: * ChakraCore/test/strict/22.callerCalleeArguments.baseline-jsc: * microbenchmarks/function-prototype-get.js: Added. * microbenchmarks/reflect-own-keys-function.js: Added. * stress/for-in-shadow-non-enumerable.js: * stress/function-hidden-as-caller.js: * stress/has-own-property-arguments.js: * stress/object-assign-fast-path.js: * stress/put-to-proto-chain-overrides-put.js: * stress/reflect-set.js: * test262/config.yaml: Skip 3 test cases that are now incorrect. * test262/expectations.yaml: Mark 2 test cases as passing. Source/JavaScriptCore: To ensure web-compatibility, only the safe subset of Function.prototype.{caller,arguments} reflection proposal [1] is implemented, which is currently shipped in SpiderMonkey. Complete list of differences from the proposed spec: 1. Cross-realm receiver function is allowed instead of throwing a TypeError. Throwing is likely safe to ship, but #225997 needs to be fixed first for custom properties to receive correct global object. 2. Cross-realm caller function is returned instead of `null`. Hiding cross-realm caller may break things: we currently have a test for the opposite behavior. 3. Defines "caller" and "arguments" setters that throw for disallowed receivers, instead failing silently in sloppy mode. This is actually more restrictive than the spec, which is preferable, and aligns with V8 and SM. Most importantly, this patch removes own "caller" and "arguments" properties from sloppy mode ES5 functions. They were non-configurable, making it harder to use their holder as a [[ProxyTarget]]. They were also non-writable, with a constantly changing [[Value]], which violated the invariants of internal methods [2]. As a result, JSFunction methods are greatly simplified, especially defineOwnProperty() and getOwnSpecialPropertyNames(). The latter is now 2.1x faster according to the provided microbenchmark. Also, removes double "prototype" lookup from [[Get]], which is a 10% progression. [1]: https://github.com/claudepache/es-legacy-function-reflection [2]: https://tc39.es/ecma262/#sec-invariants-of-the-essential-internal-methods * runtime/ClonedArguments.cpp: (JSC::ClonedArguments::getOwnPropertySlot): (JSC::ClonedArguments::materializeSpecials): * runtime/FunctionExecutable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::addFunctionProperties): (JSC::isAllowedReceiverFunctionForCallerAndArguments): (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor): (JSC::RetrieveArgumentsFunctor::result const): (JSC::RetrieveArgumentsFunctor::operator() const): (JSC::retrieveArguments): (JSC::JSC_DEFINE_CUSTOM_GETTER): (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): (JSC::RetrieveCallerFunctionFunctor::result const): (JSC::RetrieveCallerFunctionFunctor::operator() const): (JSC::retrieveCallerFunction): (JSC::JSC_DEFINE_CUSTOM_SETTER): (JSC::FunctionPrototype::initRestrictedProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnSpecialPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): (JSC::RetrieveArgumentsFunctor::RetrieveArgumentsFunctor): Deleted. (JSC::RetrieveArgumentsFunctor::result const): Deleted. (JSC::RetrieveArgumentsFunctor::operator() const): Deleted. (JSC::retrieveArguments): Deleted. (JSC::JSC_DEFINE_CUSTOM_GETTER): Deleted. (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): Deleted. (JSC::RetrieveCallerFunctionFunctor::result const): Deleted. (JSC::RetrieveCallerFunctionFunctor::operator() const): Deleted. (JSC::retrieveCallerFunction): Deleted. * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildrenImpl): * runtime/JSGlobalObject.h: Remove unused m_throwTypeErrorGetterSetter and make [[ThrowTypeError]] lazily-created. * runtime/JSGlobalObjectFunctions.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * runtime/JSGlobalObjectFunctions.h: * runtime/JSObject.cpp: (JSC::JSObject::putDirectCustomGetterSetterWithoutTransition): * runtime/JSObject.h: LayoutTests: * inspector/model/remote-object-get-properties-expected.txt: * inspector/runtime/getDisplayableProperties-expected.txt: * inspector/runtime/getProperties-expected.txt: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/kde/function_arguments-expected.txt: * js/kde/script-tests/function_arguments.js: * js/non-strict-function-properties-expected.txt: * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/non-strict-function-properties.js: * js/script-tests/throw-type-error-is-unique.js: Canonical link: https://commits.webkit.org/239947@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-07-25 22:32:20 +00:00
PASS typeof Object.getOwnPropertyDescriptor(foo, "arguments") is "undefined"
PASS typeof Object.getOwnPropertyDescriptor(foo, "caller") is "undefined"
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS foo.caller is null
PASS foo.arguments is null
PASS foo.caller is null
PASS foo.arguments is null
PASS boo("abc")[0] is "abc"
PASS boo("expected-value")[0] is "expected-value"
PASS g(f) is g
[JSC] ES6 Method functions should not have prototype https://bugs.webkit.org/show_bug.cgi?id=162530 Reviewed by Saam Barati. JSTests: Fix test262 expectations about MethodDefinitions * ChakraCore/test/strict/05.arguments_sm.baseline-jsc: * stress/reflect-set.js: * test262.yaml: Source/JavaScriptCore: ECMA-262 only adds "prototype" properties to specific syntactic function forms. Specific items which do not contain "prototype" include (most) built-in functions (such as Math.pow), MethodDefinitions which are not either class "constructor" methods or GeneratorMethods, AsyncFunctions, and ArrowFunctions. For details, see the following spec text, and the difference between GeneratorMethod evaluation and the evaluation of other MethodDefinition forms. - https://tc39.github.io/ecma262/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation - https://tc39.github.io/ecma262/#sec-arrow-function-definitions-runtime-semantics-evaluation - https://tc39.github.io/ecmascript-asyncawait/#async-function-instances - https://tc39.github.io/ecma262/#sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation * runtime/Executable.h: * runtime/JSFunction.cpp: (JSC::JSFunction::callerGetter): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::deleteProperty): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::makeFunction): * runtime/Executable.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncThrowTypeErrorArgumentsCalleeAndCaller): LayoutTests: Update expected error message to no longer indicate "strict mode" (which is not always true), and add additional tests for the presence of "caller" and "arguments" on accessor MethodDefinitions. * js/basic-strict-mode-expected.txt: * js/caller-property-expected.txt: * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: * js/non-strict-function-properties-expected.txt: * js/script-tests/caller-property.js: * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: (k.get getter): (k.set setter): (get checkProperties): * js/script-tests/non-strict-function-properties.js: Canonical link: https://commits.webkit.org/181374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207461 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-18 12:51:33 +00:00
PASS doSetCaller(value, false) threw exception TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context..
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS doSetCaller(value, true).__proto__.caller is value
[JSC] ES6 Method functions should not have prototype https://bugs.webkit.org/show_bug.cgi?id=162530 Reviewed by Saam Barati. JSTests: Fix test262 expectations about MethodDefinitions * ChakraCore/test/strict/05.arguments_sm.baseline-jsc: * stress/reflect-set.js: * test262.yaml: Source/JavaScriptCore: ECMA-262 only adds "prototype" properties to specific syntactic function forms. Specific items which do not contain "prototype" include (most) built-in functions (such as Math.pow), MethodDefinitions which are not either class "constructor" methods or GeneratorMethods, AsyncFunctions, and ArrowFunctions. For details, see the following spec text, and the difference between GeneratorMethod evaluation and the evaluation of other MethodDefinition forms. - https://tc39.github.io/ecma262/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation - https://tc39.github.io/ecma262/#sec-arrow-function-definitions-runtime-semantics-evaluation - https://tc39.github.io/ecmascript-asyncawait/#async-function-instances - https://tc39.github.io/ecma262/#sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation * runtime/Executable.h: * runtime/JSFunction.cpp: (JSC::JSFunction::callerGetter): (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::deleteProperty): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::makeFunction): * runtime/Executable.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObjectFunctions.cpp: (JSC::globalFuncThrowTypeErrorArgumentsCalleeAndCaller): LayoutTests: Update expected error message to no longer indicate "strict mode" (which is not always true), and add additional tests for the presence of "caller" and "arguments" on accessor MethodDefinitions. * js/basic-strict-mode-expected.txt: * js/caller-property-expected.txt: * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: * js/non-strict-function-properties-expected.txt: * js/script-tests/caller-property.js: * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: (k.get getter): (k.set setter): (get checkProperties): * js/script-tests/non-strict-function-properties.js: Canonical link: https://commits.webkit.org/181374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207461 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-18 12:51:33 +00:00
PASS doSetArguments(value, false) threw exception TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context..
ES6: Classes: Should be allowed to create a static method with name "arguments" https://bugs.webkit.org/show_bug.cgi?id=152985 Reviewed by Keith Miller. Source/JavaScriptCore: Current patch covered 16.2 Forbidden Extensions - first topic (https://tc39.github.io/ecma262/#sec-forbidden-extensions) ECMAScript Functions should not have own properties named "caller" or "arguments". Also added possibility to declare static methods and getters with name 'arguments' and 'caller' for classes. i.e.: class A { static arguments() { return 'value'; } } A.arguments() === 'value'; To implement this patch 'caller' and 'arguments' were put to the FunctionPrototype object. Also was changed approach to init throwTypeErrorArgumentsCalleeAndCallerGetterSetter property from Lazy to common because it necessary to use execState during init of the accessors properties. * runtime/Executable.h: * runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::initRestrictedProperties): (JSC::FunctionPrototype::addFunctionProperties): Deleted. * runtime/FunctionPrototype.h: * runtime/JSFunction.cpp: (JSC::JSFunction::getOwnPropertySlot): (JSC::JSFunction::getOwnNonIndexPropertyNames): (JSC::JSFunction::put): (JSC::JSFunction::deleteProperty): (JSC::JSFunction::defineOwnProperty): * runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::visitChildren): * runtime/JSGlobalObject.h: (JSC::JSGlobalObject::throwTypeErrorArgumentsCalleeAndCallerGetterSetter): JSTests: * test262.yaml: LayoutTests: * js/Object-getOwnPropertyNames-expected.txt: * js/basic-strict-mode-expected.txt: * js/class-method-and-constructor-properties-expected.txt: Removed. * js/class-syntax-method-names-expected.txt: * js/es6-function-properties-expected.txt: Added. * js/es6-function-properties.html: Copied from LayoutTests/js/class-method-and-constructor-properties.html. * js/kde/script-tests/function_arguments.js: (f): * js/non-strict-function-properties-expected.txt: Added. * js/non-strict-function-properties.html: Renamed from LayoutTests/js/class-method-and-constructor-properties.html. * js/script-tests/Object-getOwnPropertyNames.js: * js/script-tests/basic-strict-mode.js: * js/script-tests/class-method-and-constructor-properties.js: Removed. (shouldThrow): Deleted. (shouldBe): Deleted. (A): Deleted. (B): Deleted. (C): Deleted. (D): Deleted. (E.prototype.getItem): Deleted. (E): Deleted. (F.prototype.getElement): Deleted. (F): Deleted. (G.prototype.get item): Deleted. (G): Deleted. (H.prototype.caller): Deleted. (H.prototype.arguments): Deleted. (H): Deleted. * js/script-tests/class-syntax-method-names.js: * js/script-tests/es6-function-properties.js: Added. (shouldThrow): (shouldBe): (A): (B): (C): (D): (E.prototype.getItem): (E): (F.prototype.getElement): (F): (G.prototype.get item): (G): (check): (arr): (H.prototype.caller): (H.prototype.arguments): (H): (J.prototype.gen): (J.gen): (J): * js/script-tests/non-strict-function-properties.js: Added. (foo): (boo): (f): (g): (doSetCaller): (doSetArguments): * js/script-tests/strict-throw-type-error.js: Canonical link: https://commits.webkit.org/180055@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@205856 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-09-13 08:17:39 +00:00
PASS doSetArguments(value, true).__proto__.arguments is value
PASS successfullyParsed is true
TEST COMPLETE