haikuwebkit/LayoutTests/js/getOwnPropertyDescriptor-un...

127 lines
5.8 KiB
Plaintext
Raw Permalink Normal View History

Object.getOwnPropertyDescriptor() returns incomplete descriptor for instance properties https://bugs.webkit.org/show_bug.cgi?id=153817 Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C HTML test now that more checks are passing. Some checks are still failing because getter.call(undefined) / getter.call() currently throws an exception for Window properties but shouldn't. Global object property getters should not require an explicit |this|. * web-platform-tests/html/dom/interfaces-expected.txt: Source/JavaScriptCore: Extend support for Object.getOwnPropertyDescriptor() on native bindings to instance properties (e.g. Unforgeable properties or Global object properties) so that the returned descriptor has getter / setter functions, as expected. * runtime/JSObject.cpp: (JSC::JSObject::reifyAllStaticProperties): Add method that reifies all static properties, including the custom accessors. This is similar to what is done eagerly on the prototype objects in the bindings code. (JSC::JSObject::getOwnPropertyDescriptor): getOwnPropertyDescriptor() would previously fails for custom accessors that are on the instance because getDirect() does not check the static property table and those custom accessors were not reified (We only reified all properties eagerly - including custom accessors - on prototype objects. To address this issue, we now call reifyAllStaticProperties() if the call to getDirect() fails and then call getDirect() again. This fix is however insufficient for Window properties because |this| is a JSDOMWindowShell / JSProxy in this case and getDirect() / reifyAllStaticProperties() would fail as the proxy does not actually have the properties. This issue was addressed by checking if |this| is a JSProxy and then using JSProxy::target() instead of |this| for the calls to getDirect() and for the reification. * runtime/JSObject.h: * runtime/Lookup.h: (JSC::reifyStaticProperty): (JSC::reifyStaticProperties): Move most code in reifyStaticProperties() to a separate function so the code can be shared with JSObject::reifyAllStaticProperties(). reifyStaticProperties() is currently called by the bindings on the prototype objects. Source/WebCore: Update the bindings generator so that property getters / setters now make sure |this| has the right type and throw a TypeError if it does not, as per: - http://heycam.github.io/webidl/#dfn-attribute-getter (step 2.4.2) - http://heycam.github.io/webidl/#dfn-attribute-setter (step 3.5) This was an issue when doing something like: Object.getOwnPropertyDescriptor(window, "location").get.call(nonWindow) We would call toJSDOMWindow(thisValue), which would return null as thisValue is not a JSDOMWindow. We would then dereference this null pointer and crash. We now do a null check and throw a TypeError in this case, as per the Web IDL specification. The generated bindings still have some non-spec compliant behavior though: 1. The getters / setters of instance properties use slotBase instead of thisValue, which means that calling instanceA's getter on instanceB returns instanceA's property insteas of instanceB's. 2. Global object property getters should not require an explicit |this| so calling the following should work: - Object.getOwnPropertyDescriptor(window, "location").get.call() We currently throw in this case. These issues will be addressed in follow-up patches. Tests: js/getOwnPropertyDescriptor-unforgeable-attributes.html js/getOwnPropertyDescriptor-window-attributes.html js/instance-property-getter-other-instance.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectExcitingAttr): * bindings/scripts/test/JS/JSTestException.cpp: (WebCore::jsTestExceptionName): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjConstructorTestSubObj): (WebCore::jsTestObjTestSubObjEnabledBySettingConstructor): (WebCore::jsTestObjConditionalAttr4Constructor): (WebCore::jsTestObjConditionalAttr5Constructor): (WebCore::jsTestObjConditionalAttr6Constructor): (WebCore::jsTestObjContentDocument): (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor): (WebCore::setJSTestObjConditionalAttr4Constructor): (WebCore::setJSTestObjConditionalAttr5Constructor): (WebCore::setJSTestObjConditionalAttr6Constructor): (WebCore::setJSTestObjConstructor): Deleted. (WebCore::setJSTestObjConstructorStaticStringAttr): Deleted. (WebCore::setJSTestObjConditionalAttr3): Deleted. * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::jsTestTypedefsConstructorTestSubObj): LayoutTests: Add layout test coverage for calling Object.getOwnPropertyDescriptor() on instance properties (e.g. Unforgeable properties and Window properties). * http/tests/security/cross-origin-window-property-access-expected.txt: * http/tests/security/cross-origin-window-property-access.html: - Fix bug causing the onload function to not find the crossOriginWindow variable. - Update the case for accessing crossOriginWindow.location property as this is actually expected to work as per the specification: https://html.spec.whatwg.org/multipage/browsers.html#security-window * js/dom/dom-as-prototype-assignment-exception-expected.txt: * js/dom/getOwnPropertyDescriptor-expected.txt: * js/dom/script-tests/dom-as-prototype-assignment-exception.js: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Added. * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-window-attributes.html: Added. * js/instance-property-getter-other-instance-expected.txt: Added. * js/instance-property-getter-other-instance.html: Added. * js/resources/getOwnPropertyDescriptor.js: Canonical link: https://commits.webkit.org/171987@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-04 21:36:04 +00:00
Tests that Object.getOwnPropertyDescriptor() works correctly for [Unforgeable] IDL attributes.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
* Document.location
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Document.location getter can only be used on instances of Document.
PASS descriptor.get.call(document) is document.location
* Location.href
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.href getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.href is true
* Location.protocol
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.protocol getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.protocol is true
* Location.host
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.host getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.host is true
* Location.hostname
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.hostname getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.hostname is true
* Location.port
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.port getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.port is true
* Location.pathname
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.pathname getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.pathname is true
* Location.search
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.search getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.search is true
* Location.hash
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.hash getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.hash is true
* Location.origin
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.origin getter can only be used on instances of Location.
PASS descriptor.get.call(document.location) === document.location.origin is true
* Location.ancestorOrigins
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Location.ancestorOrigins getter can only be used on instances of Location.
* Window.location
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
Binding generator should expose the visible interface name in error messages https://bugs.webkit.org/show_bug.cgi?id=160192 Source/WebCore: Patch by Youenn Fablet <youenn@apple.com> on 2016-07-28 Reviewed by Darin Adler. Covered by updated layout and binding tests. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): Using visibleInterfaceName instead of interfaceName. (GenerateFunctionCastedThis): Ditto. (GenerateParametersCheck): Ditto. (GenerateConstructorDefinition): Ditto. * bindings/scripts/test/JS/JSTestObj.cpp: Rebased. * bindings/scripts/test/TestObj.idl: Adding ConstructorCallWith to exercice change in GenerateConstructorDefinition. LayoutTests: Patch by Youenn Fablet <youennf@gmail.com> on 2016-07-28 Reviewed by Darin Adler. * editing/selection/extend-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter.html: * fetch/fetch-error-messages-expected.txt: * fetch/fetch-error-messages.html: Adding test for Request. * js/dom/toString-and-valueOf-override-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode.html: Canonical link: https://commits.webkit.org/178482@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-29 06:45:21 +00:00
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Window.location getter can only be used on instances of Window.
Object.getOwnPropertyDescriptor() returns incomplete descriptor for instance properties https://bugs.webkit.org/show_bug.cgi?id=153817 Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C HTML test now that more checks are passing. Some checks are still failing because getter.call(undefined) / getter.call() currently throws an exception for Window properties but shouldn't. Global object property getters should not require an explicit |this|. * web-platform-tests/html/dom/interfaces-expected.txt: Source/JavaScriptCore: Extend support for Object.getOwnPropertyDescriptor() on native bindings to instance properties (e.g. Unforgeable properties or Global object properties) so that the returned descriptor has getter / setter functions, as expected. * runtime/JSObject.cpp: (JSC::JSObject::reifyAllStaticProperties): Add method that reifies all static properties, including the custom accessors. This is similar to what is done eagerly on the prototype objects in the bindings code. (JSC::JSObject::getOwnPropertyDescriptor): getOwnPropertyDescriptor() would previously fails for custom accessors that are on the instance because getDirect() does not check the static property table and those custom accessors were not reified (We only reified all properties eagerly - including custom accessors - on prototype objects. To address this issue, we now call reifyAllStaticProperties() if the call to getDirect() fails and then call getDirect() again. This fix is however insufficient for Window properties because |this| is a JSDOMWindowShell / JSProxy in this case and getDirect() / reifyAllStaticProperties() would fail as the proxy does not actually have the properties. This issue was addressed by checking if |this| is a JSProxy and then using JSProxy::target() instead of |this| for the calls to getDirect() and for the reification. * runtime/JSObject.h: * runtime/Lookup.h: (JSC::reifyStaticProperty): (JSC::reifyStaticProperties): Move most code in reifyStaticProperties() to a separate function so the code can be shared with JSObject::reifyAllStaticProperties(). reifyStaticProperties() is currently called by the bindings on the prototype objects. Source/WebCore: Update the bindings generator so that property getters / setters now make sure |this| has the right type and throw a TypeError if it does not, as per: - http://heycam.github.io/webidl/#dfn-attribute-getter (step 2.4.2) - http://heycam.github.io/webidl/#dfn-attribute-setter (step 3.5) This was an issue when doing something like: Object.getOwnPropertyDescriptor(window, "location").get.call(nonWindow) We would call toJSDOMWindow(thisValue), which would return null as thisValue is not a JSDOMWindow. We would then dereference this null pointer and crash. We now do a null check and throw a TypeError in this case, as per the Web IDL specification. The generated bindings still have some non-spec compliant behavior though: 1. The getters / setters of instance properties use slotBase instead of thisValue, which means that calling instanceA's getter on instanceB returns instanceA's property insteas of instanceB's. 2. Global object property getters should not require an explicit |this| so calling the following should work: - Object.getOwnPropertyDescriptor(window, "location").get.call() We currently throw in this case. These issues will be addressed in follow-up patches. Tests: js/getOwnPropertyDescriptor-unforgeable-attributes.html js/getOwnPropertyDescriptor-window-attributes.html js/instance-property-getter-other-instance.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectExcitingAttr): * bindings/scripts/test/JS/JSTestException.cpp: (WebCore::jsTestExceptionName): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjConstructorTestSubObj): (WebCore::jsTestObjTestSubObjEnabledBySettingConstructor): (WebCore::jsTestObjConditionalAttr4Constructor): (WebCore::jsTestObjConditionalAttr5Constructor): (WebCore::jsTestObjConditionalAttr6Constructor): (WebCore::jsTestObjContentDocument): (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor): (WebCore::setJSTestObjConditionalAttr4Constructor): (WebCore::setJSTestObjConditionalAttr5Constructor): (WebCore::setJSTestObjConditionalAttr6Constructor): (WebCore::setJSTestObjConstructor): Deleted. (WebCore::setJSTestObjConstructorStaticStringAttr): Deleted. (WebCore::setJSTestObjConditionalAttr3): Deleted. * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::jsTestTypedefsConstructorTestSubObj): LayoutTests: Add layout test coverage for calling Object.getOwnPropertyDescriptor() on instance properties (e.g. Unforgeable properties and Window properties). * http/tests/security/cross-origin-window-property-access-expected.txt: * http/tests/security/cross-origin-window-property-access.html: - Fix bug causing the onload function to not find the crossOriginWindow variable. - Update the case for accessing crossOriginWindow.location property as this is actually expected to work as per the specification: https://html.spec.whatwg.org/multipage/browsers.html#security-window * js/dom/dom-as-prototype-assignment-exception-expected.txt: * js/dom/getOwnPropertyDescriptor-expected.txt: * js/dom/script-tests/dom-as-prototype-assignment-exception.js: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Added. * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-window-attributes.html: Added. * js/instance-property-getter-other-instance-expected.txt: Added. * js/instance-property-getter-other-instance.html: Added. * js/resources/getOwnPropertyDescriptor.js: Canonical link: https://commits.webkit.org/171987@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-04 21:36:04 +00:00
PASS descriptor.get.call(window) === window.location is true
* Window.window
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
Binding generator should expose the visible interface name in error messages https://bugs.webkit.org/show_bug.cgi?id=160192 Source/WebCore: Patch by Youenn Fablet <youenn@apple.com> on 2016-07-28 Reviewed by Darin Adler. Covered by updated layout and binding tests. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): Using visibleInterfaceName instead of interfaceName. (GenerateFunctionCastedThis): Ditto. (GenerateParametersCheck): Ditto. (GenerateConstructorDefinition): Ditto. * bindings/scripts/test/JS/JSTestObj.cpp: Rebased. * bindings/scripts/test/TestObj.idl: Adding ConstructorCallWith to exercice change in GenerateConstructorDefinition. LayoutTests: Patch by Youenn Fablet <youennf@gmail.com> on 2016-07-28 Reviewed by Darin Adler. * editing/selection/extend-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter.html: * fetch/fetch-error-messages-expected.txt: * fetch/fetch-error-messages.html: Adding test for Request. * js/dom/toString-and-valueOf-override-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode.html: Canonical link: https://commits.webkit.org/178482@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-29 06:45:21 +00:00
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Window.window getter can only be used on instances of Window.
Object.getOwnPropertyDescriptor() returns incomplete descriptor for instance properties https://bugs.webkit.org/show_bug.cgi?id=153817 Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C HTML test now that more checks are passing. Some checks are still failing because getter.call(undefined) / getter.call() currently throws an exception for Window properties but shouldn't. Global object property getters should not require an explicit |this|. * web-platform-tests/html/dom/interfaces-expected.txt: Source/JavaScriptCore: Extend support for Object.getOwnPropertyDescriptor() on native bindings to instance properties (e.g. Unforgeable properties or Global object properties) so that the returned descriptor has getter / setter functions, as expected. * runtime/JSObject.cpp: (JSC::JSObject::reifyAllStaticProperties): Add method that reifies all static properties, including the custom accessors. This is similar to what is done eagerly on the prototype objects in the bindings code. (JSC::JSObject::getOwnPropertyDescriptor): getOwnPropertyDescriptor() would previously fails for custom accessors that are on the instance because getDirect() does not check the static property table and those custom accessors were not reified (We only reified all properties eagerly - including custom accessors - on prototype objects. To address this issue, we now call reifyAllStaticProperties() if the call to getDirect() fails and then call getDirect() again. This fix is however insufficient for Window properties because |this| is a JSDOMWindowShell / JSProxy in this case and getDirect() / reifyAllStaticProperties() would fail as the proxy does not actually have the properties. This issue was addressed by checking if |this| is a JSProxy and then using JSProxy::target() instead of |this| for the calls to getDirect() and for the reification. * runtime/JSObject.h: * runtime/Lookup.h: (JSC::reifyStaticProperty): (JSC::reifyStaticProperties): Move most code in reifyStaticProperties() to a separate function so the code can be shared with JSObject::reifyAllStaticProperties(). reifyStaticProperties() is currently called by the bindings on the prototype objects. Source/WebCore: Update the bindings generator so that property getters / setters now make sure |this| has the right type and throw a TypeError if it does not, as per: - http://heycam.github.io/webidl/#dfn-attribute-getter (step 2.4.2) - http://heycam.github.io/webidl/#dfn-attribute-setter (step 3.5) This was an issue when doing something like: Object.getOwnPropertyDescriptor(window, "location").get.call(nonWindow) We would call toJSDOMWindow(thisValue), which would return null as thisValue is not a JSDOMWindow. We would then dereference this null pointer and crash. We now do a null check and throw a TypeError in this case, as per the Web IDL specification. The generated bindings still have some non-spec compliant behavior though: 1. The getters / setters of instance properties use slotBase instead of thisValue, which means that calling instanceA's getter on instanceB returns instanceA's property insteas of instanceB's. 2. Global object property getters should not require an explicit |this| so calling the following should work: - Object.getOwnPropertyDescriptor(window, "location").get.call() We currently throw in this case. These issues will be addressed in follow-up patches. Tests: js/getOwnPropertyDescriptor-unforgeable-attributes.html js/getOwnPropertyDescriptor-window-attributes.html js/instance-property-getter-other-instance.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectExcitingAttr): * bindings/scripts/test/JS/JSTestException.cpp: (WebCore::jsTestExceptionName): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjConstructorTestSubObj): (WebCore::jsTestObjTestSubObjEnabledBySettingConstructor): (WebCore::jsTestObjConditionalAttr4Constructor): (WebCore::jsTestObjConditionalAttr5Constructor): (WebCore::jsTestObjConditionalAttr6Constructor): (WebCore::jsTestObjContentDocument): (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor): (WebCore::setJSTestObjConditionalAttr4Constructor): (WebCore::setJSTestObjConditionalAttr5Constructor): (WebCore::setJSTestObjConditionalAttr6Constructor): (WebCore::setJSTestObjConstructor): Deleted. (WebCore::setJSTestObjConstructorStaticStringAttr): Deleted. (WebCore::setJSTestObjConditionalAttr3): Deleted. * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::jsTestTypedefsConstructorTestSubObj): LayoutTests: Add layout test coverage for calling Object.getOwnPropertyDescriptor() on instance properties (e.g. Unforgeable properties and Window properties). * http/tests/security/cross-origin-window-property-access-expected.txt: * http/tests/security/cross-origin-window-property-access.html: - Fix bug causing the onload function to not find the crossOriginWindow variable. - Update the case for accessing crossOriginWindow.location property as this is actually expected to work as per the specification: https://html.spec.whatwg.org/multipage/browsers.html#security-window * js/dom/dom-as-prototype-assignment-exception-expected.txt: * js/dom/getOwnPropertyDescriptor-expected.txt: * js/dom/script-tests/dom-as-prototype-assignment-exception.js: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Added. * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-window-attributes.html: Added. * js/instance-property-getter-other-instance-expected.txt: Added. * js/instance-property-getter-other-instance.html: Added. * js/resources/getOwnPropertyDescriptor.js: Canonical link: https://commits.webkit.org/171987@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-04 21:36:04 +00:00
PASS descriptor.get.call(window) === window.window is true
* Window.top
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
Binding generator should expose the visible interface name in error messages https://bugs.webkit.org/show_bug.cgi?id=160192 Source/WebCore: Patch by Youenn Fablet <youenn@apple.com> on 2016-07-28 Reviewed by Darin Adler. Covered by updated layout and binding tests. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): Using visibleInterfaceName instead of interfaceName. (GenerateFunctionCastedThis): Ditto. (GenerateParametersCheck): Ditto. (GenerateConstructorDefinition): Ditto. * bindings/scripts/test/JS/JSTestObj.cpp: Rebased. * bindings/scripts/test/TestObj.idl: Adding ConstructorCallWith to exercice change in GenerateConstructorDefinition. LayoutTests: Patch by Youenn Fablet <youennf@gmail.com> on 2016-07-28 Reviewed by Darin Adler. * editing/selection/extend-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter.html: * fetch/fetch-error-messages-expected.txt: * fetch/fetch-error-messages.html: Adding test for Request. * js/dom/toString-and-valueOf-override-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode.html: Canonical link: https://commits.webkit.org/178482@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-29 06:45:21 +00:00
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Window.top getter can only be used on instances of Window.
Object.getOwnPropertyDescriptor() returns incomplete descriptor for instance properties https://bugs.webkit.org/show_bug.cgi?id=153817 Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C HTML test now that more checks are passing. Some checks are still failing because getter.call(undefined) / getter.call() currently throws an exception for Window properties but shouldn't. Global object property getters should not require an explicit |this|. * web-platform-tests/html/dom/interfaces-expected.txt: Source/JavaScriptCore: Extend support for Object.getOwnPropertyDescriptor() on native bindings to instance properties (e.g. Unforgeable properties or Global object properties) so that the returned descriptor has getter / setter functions, as expected. * runtime/JSObject.cpp: (JSC::JSObject::reifyAllStaticProperties): Add method that reifies all static properties, including the custom accessors. This is similar to what is done eagerly on the prototype objects in the bindings code. (JSC::JSObject::getOwnPropertyDescriptor): getOwnPropertyDescriptor() would previously fails for custom accessors that are on the instance because getDirect() does not check the static property table and those custom accessors were not reified (We only reified all properties eagerly - including custom accessors - on prototype objects. To address this issue, we now call reifyAllStaticProperties() if the call to getDirect() fails and then call getDirect() again. This fix is however insufficient for Window properties because |this| is a JSDOMWindowShell / JSProxy in this case and getDirect() / reifyAllStaticProperties() would fail as the proxy does not actually have the properties. This issue was addressed by checking if |this| is a JSProxy and then using JSProxy::target() instead of |this| for the calls to getDirect() and for the reification. * runtime/JSObject.h: * runtime/Lookup.h: (JSC::reifyStaticProperty): (JSC::reifyStaticProperties): Move most code in reifyStaticProperties() to a separate function so the code can be shared with JSObject::reifyAllStaticProperties(). reifyStaticProperties() is currently called by the bindings on the prototype objects. Source/WebCore: Update the bindings generator so that property getters / setters now make sure |this| has the right type and throw a TypeError if it does not, as per: - http://heycam.github.io/webidl/#dfn-attribute-getter (step 2.4.2) - http://heycam.github.io/webidl/#dfn-attribute-setter (step 3.5) This was an issue when doing something like: Object.getOwnPropertyDescriptor(window, "location").get.call(nonWindow) We would call toJSDOMWindow(thisValue), which would return null as thisValue is not a JSDOMWindow. We would then dereference this null pointer and crash. We now do a null check and throw a TypeError in this case, as per the Web IDL specification. The generated bindings still have some non-spec compliant behavior though: 1. The getters / setters of instance properties use slotBase instead of thisValue, which means that calling instanceA's getter on instanceB returns instanceA's property insteas of instanceB's. 2. Global object property getters should not require an explicit |this| so calling the following should work: - Object.getOwnPropertyDescriptor(window, "location").get.call() We currently throw in this case. These issues will be addressed in follow-up patches. Tests: js/getOwnPropertyDescriptor-unforgeable-attributes.html js/getOwnPropertyDescriptor-window-attributes.html js/instance-property-getter-other-instance.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectExcitingAttr): * bindings/scripts/test/JS/JSTestException.cpp: (WebCore::jsTestExceptionName): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjConstructorTestSubObj): (WebCore::jsTestObjTestSubObjEnabledBySettingConstructor): (WebCore::jsTestObjConditionalAttr4Constructor): (WebCore::jsTestObjConditionalAttr5Constructor): (WebCore::jsTestObjConditionalAttr6Constructor): (WebCore::jsTestObjContentDocument): (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor): (WebCore::setJSTestObjConditionalAttr4Constructor): (WebCore::setJSTestObjConditionalAttr5Constructor): (WebCore::setJSTestObjConditionalAttr6Constructor): (WebCore::setJSTestObjConstructor): Deleted. (WebCore::setJSTestObjConstructorStaticStringAttr): Deleted. (WebCore::setJSTestObjConditionalAttr3): Deleted. * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::jsTestTypedefsConstructorTestSubObj): LayoutTests: Add layout test coverage for calling Object.getOwnPropertyDescriptor() on instance properties (e.g. Unforgeable properties and Window properties). * http/tests/security/cross-origin-window-property-access-expected.txt: * http/tests/security/cross-origin-window-property-access.html: - Fix bug causing the onload function to not find the crossOriginWindow variable. - Update the case for accessing crossOriginWindow.location property as this is actually expected to work as per the specification: https://html.spec.whatwg.org/multipage/browsers.html#security-window * js/dom/dom-as-prototype-assignment-exception-expected.txt: * js/dom/getOwnPropertyDescriptor-expected.txt: * js/dom/script-tests/dom-as-prototype-assignment-exception.js: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Added. * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-window-attributes.html: Added. * js/instance-property-getter-other-instance-expected.txt: Added. * js/instance-property-getter-other-instance.html: Added. * js/resources/getOwnPropertyDescriptor.js: Canonical link: https://commits.webkit.org/171987@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-04 21:36:04 +00:00
PASS descriptor.get.call(window) === window.top is true
* Window.document
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
PASS descriptor.enumerable is true
PASS descriptor.configurable is false
Binding generator should expose the visible interface name in error messages https://bugs.webkit.org/show_bug.cgi?id=160192 Source/WebCore: Patch by Youenn Fablet <youenn@apple.com> on 2016-07-28 Reviewed by Darin Adler. Covered by updated layout and binding tests. * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): Using visibleInterfaceName instead of interfaceName. (GenerateFunctionCastedThis): Ditto. (GenerateParametersCheck): Ditto. (GenerateConstructorDefinition): Ditto. * bindings/scripts/test/JS/JSTestObj.cpp: Rebased. * bindings/scripts/test/TestObj.idl: Adding ConstructorCallWith to exercice change in GenerateConstructorDefinition. LayoutTests: Patch by Youenn Fablet <youennf@gmail.com> on 2016-07-28 Reviewed by Darin Adler. * editing/selection/extend-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter-expected.txt: * fast/dom/Window/getComputedStyle-missing-parameter.html: * fetch/fetch-error-messages-expected.txt: * fetch/fetch-error-messages.html: Adding test for Request. * js/dom/toString-and-valueOf-override-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax-expected.txt: * media/encrypted-media/encrypted-media-v2-syntax.html: * webaudio/createMediaStreamSource-null-expected.txt: * webaudio/createMediaStreamSource-null.html: * webaudio/decode-audio-data-basic-expected.txt: * webaudio/decode-audio-data-basic.html: * webaudio/mediaelementaudiosourcenode-expected.txt: * webaudio/mediaelementaudiosourcenode.html: Canonical link: https://commits.webkit.org/178482@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203858 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-29 06:45:21 +00:00
PASS descriptor.get.call(invalidObject) threw exception TypeError: The Window.document getter can only be used on instances of Window.
Object.getOwnPropertyDescriptor() returns incomplete descriptor for instance properties https://bugs.webkit.org/show_bug.cgi?id=153817 Reviewed by Geoffrey Garen. LayoutTests/imported/w3c: Rebaseline W3C HTML test now that more checks are passing. Some checks are still failing because getter.call(undefined) / getter.call() currently throws an exception for Window properties but shouldn't. Global object property getters should not require an explicit |this|. * web-platform-tests/html/dom/interfaces-expected.txt: Source/JavaScriptCore: Extend support for Object.getOwnPropertyDescriptor() on native bindings to instance properties (e.g. Unforgeable properties or Global object properties) so that the returned descriptor has getter / setter functions, as expected. * runtime/JSObject.cpp: (JSC::JSObject::reifyAllStaticProperties): Add method that reifies all static properties, including the custom accessors. This is similar to what is done eagerly on the prototype objects in the bindings code. (JSC::JSObject::getOwnPropertyDescriptor): getOwnPropertyDescriptor() would previously fails for custom accessors that are on the instance because getDirect() does not check the static property table and those custom accessors were not reified (We only reified all properties eagerly - including custom accessors - on prototype objects. To address this issue, we now call reifyAllStaticProperties() if the call to getDirect() fails and then call getDirect() again. This fix is however insufficient for Window properties because |this| is a JSDOMWindowShell / JSProxy in this case and getDirect() / reifyAllStaticProperties() would fail as the proxy does not actually have the properties. This issue was addressed by checking if |this| is a JSProxy and then using JSProxy::target() instead of |this| for the calls to getDirect() and for the reification. * runtime/JSObject.h: * runtime/Lookup.h: (JSC::reifyStaticProperty): (JSC::reifyStaticProperties): Move most code in reifyStaticProperties() to a separate function so the code can be shared with JSObject::reifyAllStaticProperties(). reifyStaticProperties() is currently called by the bindings on the prototype objects. Source/WebCore: Update the bindings generator so that property getters / setters now make sure |this| has the right type and throw a TypeError if it does not, as per: - http://heycam.github.io/webidl/#dfn-attribute-getter (step 2.4.2) - http://heycam.github.io/webidl/#dfn-attribute-setter (step 3.5) This was an issue when doing something like: Object.getOwnPropertyDescriptor(window, "location").get.call(nonWindow) We would call toJSDOMWindow(thisValue), which would return null as thisValue is not a JSDOMWindow. We would then dereference this null pointer and crash. We now do a null check and throw a TypeError in this case, as per the Web IDL specification. The generated bindings still have some non-spec compliant behavior though: 1. The getters / setters of instance properties use slotBase instead of thisValue, which means that calling instanceA's getter on instanceB returns instanceA's property insteas of instanceB's. 2. Global object property getters should not require an explicit |this| so calling the following should work: - Object.getOwnPropertyDescriptor(window, "location").get.call() We currently throw in this case. These issues will be addressed in follow-up patches. Tests: js/getOwnPropertyDescriptor-unforgeable-attributes.html js/getOwnPropertyDescriptor-window-attributes.html js/instance-property-getter-other-instance.html * bindings/scripts/CodeGeneratorJS.pm: (GenerateImplementation): * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: (WebCore::jsTestActiveDOMObjectExcitingAttr): * bindings/scripts/test/JS/JSTestException.cpp: (WebCore::jsTestExceptionName): * bindings/scripts/test/JS/JSTestObj.cpp: (WebCore::jsTestObjConstructorTestSubObj): (WebCore::jsTestObjTestSubObjEnabledBySettingConstructor): (WebCore::jsTestObjConditionalAttr4Constructor): (WebCore::jsTestObjConditionalAttr5Constructor): (WebCore::jsTestObjConditionalAttr6Constructor): (WebCore::jsTestObjContentDocument): (WebCore::setJSTestObjTestSubObjEnabledBySettingConstructor): (WebCore::setJSTestObjConditionalAttr4Constructor): (WebCore::setJSTestObjConditionalAttr5Constructor): (WebCore::setJSTestObjConditionalAttr6Constructor): (WebCore::setJSTestObjConstructor): Deleted. (WebCore::setJSTestObjConstructorStaticStringAttr): Deleted. (WebCore::setJSTestObjConditionalAttr3): Deleted. * bindings/scripts/test/JS/JSTestTypedefs.cpp: (WebCore::jsTestTypedefsConstructorTestSubObj): LayoutTests: Add layout test coverage for calling Object.getOwnPropertyDescriptor() on instance properties (e.g. Unforgeable properties and Window properties). * http/tests/security/cross-origin-window-property-access-expected.txt: * http/tests/security/cross-origin-window-property-access.html: - Fix bug causing the onload function to not find the crossOriginWindow variable. - Update the case for accessing crossOriginWindow.location property as this is actually expected to work as per the specification: https://html.spec.whatwg.org/multipage/browsers.html#security-window * js/dom/dom-as-prototype-assignment-exception-expected.txt: * js/dom/getOwnPropertyDescriptor-expected.txt: * js/dom/script-tests/dom-as-prototype-assignment-exception.js: * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Added. * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Added. * js/getOwnPropertyDescriptor-window-attributes.html: Added. * js/instance-property-getter-other-instance-expected.txt: Added. * js/instance-property-getter-other-instance.html: Added. * js/resources/getOwnPropertyDescriptor.js: Canonical link: https://commits.webkit.org/171987@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196145 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-04 21:36:04 +00:00
PASS successfullyParsed is true
TEST COMPLETE