haikuwebkit/LayoutTests/js/getOwnPropertyDescriptor-wi...

67 lines
2.6 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 Window properties
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
* Window.screen
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
PASS descriptor.configurable is true
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(nonWindowObject) threw exception TypeError: The Window.screen 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.screen is true
Attribute getters should not require an explicit 'this' value for Window properties https://bugs.webkit.org/show_bug.cgi?id=153968 Reviewed by Darin Adler. LayoutTests/imported/w3c: Rebaseline W3C test now that more checks are passing. * web-platform-tests/html/dom/interfaces-expected.txt: Source/WebCore: Attribute getters should not require an explicit 'this' value for Window properties. This is because the Window interface is marked as [ImplicitThis]: - http://heycam.github.io/webidl/#ImplicitThis - https://www.w3.org/Bugs/Public/show_bug.cgi?id=29421 This matches the behavior of Firefox and the expectations of the W3C web-platform-tests. No new tests, already covered by existing tests. * bindings/scripts/CodeGeneratorJS.pm: In attribute getters of an interface marked as [ImplicitThis], if 'thisValue' is undefined or null, fall back to using the global object as 'thisValue'. * bindings/scripts/IDLAttributes.txt: Add support for [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis * bindings/scripts/test/JS/JSTestEventConstructor.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestInterface.cpp: * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp: * bindings/scripts/test/JS/JSTestNode.cpp: * bindings/scripts/test/JS/JSTestNondeterministic.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: * bindings/scripts/test/JS/JSTestTypedefs.cpp: * bindings/scripts/test/JS/JSattribute.cpp: Rebaseline bindings tests. * page/DOMWindow.idl: Mark Window as [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis LayoutTests: Rebaseline existing tests now that more checks are passing. * fast/dom/Window/getOwnPropertyDescriptor-other-window-expected.txt: * fast/dom/Window/getOwnPropertyDescriptor-other-window.html: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Canonical link: https://commits.webkit.org/172127@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-09 05:15:06 +00:00
PASS descriptor.get.call() === window.screen is true
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
* Window.navigator
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
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.enumerable is true
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
PASS descriptor.configurable is true
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(nonWindowObject) threw exception TypeError: The Window.navigator 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.navigator is true
Attribute getters should not require an explicit 'this' value for Window properties https://bugs.webkit.org/show_bug.cgi?id=153968 Reviewed by Darin Adler. LayoutTests/imported/w3c: Rebaseline W3C test now that more checks are passing. * web-platform-tests/html/dom/interfaces-expected.txt: Source/WebCore: Attribute getters should not require an explicit 'this' value for Window properties. This is because the Window interface is marked as [ImplicitThis]: - http://heycam.github.io/webidl/#ImplicitThis - https://www.w3.org/Bugs/Public/show_bug.cgi?id=29421 This matches the behavior of Firefox and the expectations of the W3C web-platform-tests. No new tests, already covered by existing tests. * bindings/scripts/CodeGeneratorJS.pm: In attribute getters of an interface marked as [ImplicitThis], if 'thisValue' is undefined or null, fall back to using the global object as 'thisValue'. * bindings/scripts/IDLAttributes.txt: Add support for [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis * bindings/scripts/test/JS/JSTestEventConstructor.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestInterface.cpp: * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp: * bindings/scripts/test/JS/JSTestNode.cpp: * bindings/scripts/test/JS/JSTestNondeterministic.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: * bindings/scripts/test/JS/JSTestTypedefs.cpp: * bindings/scripts/test/JS/JSattribute.cpp: Rebaseline bindings tests. * page/DOMWindow.idl: Mark Window as [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis LayoutTests: Rebaseline existing tests now that more checks are passing. * fast/dom/Window/getOwnPropertyDescriptor-other-window-expected.txt: * fast/dom/Window/getOwnPropertyDescriptor-other-window.html: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Canonical link: https://commits.webkit.org/172127@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-09 05:15:06 +00:00
PASS descriptor.get.call() === window.navigator is true
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
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
* Window.self
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 true
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(nonWindowObject) threw exception TypeError: The Window.self getter can only be used on instances of Window.
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
PASS descriptor.get.call(window) === window.self is true
PASS descriptor.get.call() === window.self is true
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
* Window.frameElement
PASS descriptor.get is an instance of Function
PASS descriptor.set is undefined.
PASS descriptor.enumerable is true
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
PASS descriptor.configurable is true
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(nonWindowObject) threw exception TypeError: The Window.frameElement 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.frameElement is true
Attribute getters should not require an explicit 'this' value for Window properties https://bugs.webkit.org/show_bug.cgi?id=153968 Reviewed by Darin Adler. LayoutTests/imported/w3c: Rebaseline W3C test now that more checks are passing. * web-platform-tests/html/dom/interfaces-expected.txt: Source/WebCore: Attribute getters should not require an explicit 'this' value for Window properties. This is because the Window interface is marked as [ImplicitThis]: - http://heycam.github.io/webidl/#ImplicitThis - https://www.w3.org/Bugs/Public/show_bug.cgi?id=29421 This matches the behavior of Firefox and the expectations of the W3C web-platform-tests. No new tests, already covered by existing tests. * bindings/scripts/CodeGeneratorJS.pm: In attribute getters of an interface marked as [ImplicitThis], if 'thisValue' is undefined or null, fall back to using the global object as 'thisValue'. * bindings/scripts/IDLAttributes.txt: Add support for [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis * bindings/scripts/test/JS/JSTestEventConstructor.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestInterface.cpp: * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp: * bindings/scripts/test/JS/JSTestNode.cpp: * bindings/scripts/test/JS/JSTestNondeterministic.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: * bindings/scripts/test/JS/JSTestTypedefs.cpp: * bindings/scripts/test/JS/JSattribute.cpp: Rebaseline bindings tests. * page/DOMWindow.idl: Mark Window as [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis LayoutTests: Rebaseline existing tests now that more checks are passing. * fast/dom/Window/getOwnPropertyDescriptor-other-window-expected.txt: * fast/dom/Window/getOwnPropertyDescriptor-other-window.html: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Canonical link: https://commits.webkit.org/172127@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-09 05:15:06 +00:00
PASS descriptor.get.call() === window.frameElement is true
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
* Window.name
PASS descriptor.get is an instance of Function
PASS descriptor.set is an instance of Function
PASS descriptor.enumerable is true
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
PASS descriptor.configurable is true
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(nonWindowObject) threw exception TypeError: The Window.name 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.name is true
Attribute getters should not require an explicit 'this' value for Window properties https://bugs.webkit.org/show_bug.cgi?id=153968 Reviewed by Darin Adler. LayoutTests/imported/w3c: Rebaseline W3C test now that more checks are passing. * web-platform-tests/html/dom/interfaces-expected.txt: Source/WebCore: Attribute getters should not require an explicit 'this' value for Window properties. This is because the Window interface is marked as [ImplicitThis]: - http://heycam.github.io/webidl/#ImplicitThis - https://www.w3.org/Bugs/Public/show_bug.cgi?id=29421 This matches the behavior of Firefox and the expectations of the W3C web-platform-tests. No new tests, already covered by existing tests. * bindings/scripts/CodeGeneratorJS.pm: In attribute getters of an interface marked as [ImplicitThis], if 'thisValue' is undefined or null, fall back to using the global object as 'thisValue'. * bindings/scripts/IDLAttributes.txt: Add support for [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis * bindings/scripts/test/JS/JSTestEventConstructor.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestInterface.cpp: * bindings/scripts/test/JS/JSTestJSBuiltinConstructor.cpp: * bindings/scripts/test/JS/JSTestNode.cpp: * bindings/scripts/test/JS/JSTestNondeterministic.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: * bindings/scripts/test/JS/JSTestTypedefs.cpp: * bindings/scripts/test/JS/JSattribute.cpp: Rebaseline bindings tests. * page/DOMWindow.idl: Mark Window as [ImplicitThis]: http://heycam.github.io/webidl/#ImplicitThis LayoutTests: Rebaseline existing tests now that more checks are passing. * fast/dom/Window/getOwnPropertyDescriptor-other-window-expected.txt: * fast/dom/Window/getOwnPropertyDescriptor-other-window.html: * js/getOwnPropertyDescriptor-window-attributes-expected.txt: Canonical link: https://commits.webkit.org/172127@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-09 05:15:06 +00:00
PASS descriptor.get.call() === window.name is true
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
* window.Node
PASS descriptor.enumerable is false
PASS descriptor.writable is true
PASS descriptor.configurable is true
PASS descriptor.value is window.Node
Window should have its 'constructor' property on the prototype https://bugs.webkit.org/show_bug.cgi?id=154037 <rdar://problem/24689078> Reviewed by Gavin Barraclough. LayoutTests/imported/w3c: Rebaseline W3C test now that one more check is passing. * web-platform-tests/html/dom/interfaces-expected.txt: Source/WebCore: Window should have its 'constructor' property on the prototype as per the Web IDL specification: http://heycam.github.io/webidl/#interface-prototype-object Firefox and Chrome already match the specification. No new tests, covered by: - fast/dom/Window/window-constructor-settable.html - fast/dom/Window/window-constructor.html - http/tests/security/cross-origin-window-property-access.html - imported/w3c/web-platform-tests/html/dom/interfaces.html * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Deleted. Drop this routine as all constructors are now on the prototype. (InstancePropertyCount): Do not account for constructor properties as these can only be on the prototype now. (PrototypePropertyCount): Increment the property count by 1 if the interface has a constructor property (e.g. [NoInterfaceObject] interfaces do not have one). (GeneratePropertiesHashTable): Stop calling ConstructorShouldBeOnInstance() as it no longer exists. Always generated the "constructor" property if: 1. We are generating the prototype hash table. and 2. The interface needs a constructor (i.e. not marked as [NoInterfaceObject]). (GenerateImplementation): - Drop code handling the case where ConstructorShouldBeOnInstance() returns true as constructors are not always on the prototype and the ConstructorShouldBeOnInstance() routine has been dropped. - Drop code handling [CustomProxyToJSObject]. Now that the constructor is always on the prototype, we never need to cast thisValue to a JSDOMWindow (by calling toJSDOMWindow). In the Window case, thisValue is now casted to a JSDOMWindowPrototype*, similarly to other interfaces so we don't need a special casting function anymore. - Stop generating security checks. This only impacts Window as it is the only interface marked as [CheckSecurity]. The cross-origin checking code as it was would not work when "constructor" is on the prototype because thisValue is a JSDOMWindowPrototype, not a JSDOMWindow and we have no way of getting the wrapped window. Also, the security check is no longer needed because: 1. Accessing crossOriginWindow.constructor will not work now that constructor is on the prototype because JSDOMWindow::getOwnPropertySlot() already prevents access to the prototype in the cross-origin case. 2. "constructor" is a value property, not a getter/setter. Therefore, it is no possible to use the getter/setter from a same origin window instance and call it on a cross origin window. LayoutTests: * http/tests/security/cross-origin-window-property-access-expected.txt: * http/tests/security/cross-origin-window-property-access.html: Add checks to make sure it still is not possible to access window.constructor cross-origin. * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: Update test now that window has it's "constructor" attribute on the prototype. Canonical link: https://commits.webkit.org/172445@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196690 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-17 08:38:27 +00:00
* window.__proto__.constructor
Attributes on the Window instance should be configurable unless [Unforgeable] https://bugs.webkit.org/show_bug.cgi?id=153920 <rdar://problem/24563211> Reviewed by Darin Adler. Source/JavaScriptCore: Marking the Window instance attributes as configurable but cause getOwnPropertyDescriptor() to report them as configurable, as expected. However, trying to delete them would actually lead to unexpected behavior because: - We did not reify custom accessor properties (most of the Window properties are custom accessors) upon deletion. - For non-reified static properties marked as configurable, JSObject::deleteProperty() would attempt to call the property setter with undefined. As a result, calling delete window.name would cause window.name to become the string "undefined" instead of the undefined value. * runtime/JSObject.cpp: (JSC::getClassPropertyNames): Now that we reify ALL properties, we only need to check the property table if we have not reified. As a result, I dropped the 'didReify' parameter for this function and instead only call this function if we have not yet reified. (JSC::JSObject::putInlineSlow): Only call putEntry() if we have not reified: Drop the '|| !(entry->attributes() & BuiltinOrFunctionOrAccessor)' check as such properties now get reified as well. (JSC::JSObject::deleteProperty): - Call reifyAllStaticProperties() instead of reifyStaticFunctionsForDelete() so that we now reify all properties upon deletion, including the custom accessors. reifyStaticFunctionsForDelete() is now removed and the same reification function is now used by: deletion, getOwnPropertyDescriptor() and eager reification of the prototype objects in the bindings. - Drop code that falls back to calling the static property setter with undefined if we cannot find the property in the property storage. As we now reify ALL properties, the code removing the property from the property storage should succeed, provided that the property actually exists. (JSC::JSObject::getOwnNonIndexPropertyNames): Only call getClassPropertyNames() if we have not reified. We should no longer check the static property table after reifying now that we reify all properties. (JSC::JSObject::reifyAllStaticProperties): Merge with reifyStaticFunctionsForDelete(). The only behavior change is the flattening to an uncacheable dictionary, like reifyStaticFunctionsForDelete() used to do. * runtime/JSObject.h: Source/WebCore: Attributes on the Window instance should be configurable unless [Unforgeable]: 1. 'constructor' property: - http://www.w3.org/TR/WebIDL/#interface-prototype-object 2. Constructor properties (e.g. window.Node): - http://www.w3.org/TR/WebIDL/#es-interfaces 3. IDL attributes: - http://heycam.github.io/webidl/#es-attributes (configurable unless [Unforgeable], e.g. window.location) Firefox complies with the WebIDL specification but WebKit does not for 1. and 3. Test: fast/dom/Window/window-properties-configurable.html * bindings/js/JSDOMWindowCustom.cpp: (WebCore::JSDOMWindow::getOwnPropertySlot): For known Window properties (i.e. properties in the static property table), if we have reified and this is same-origin access, then call Base::getOwnPropertySlot() to get the property from the local property storage. If we have not reified yet, or this is cross-origin access, query the static property table. This is to match the behavior of Firefox and Chrome which seem to keep returning the original properties upon cross origin access, even if those were deleted or redefined. (WebCore::JSDOMWindow::put): The previous code used to call the static property setter for properties in the static table. However, this does not do the right thing if properties were reified. For example, deleting window.name and then trying to set it again would not work. Therefore, update this code to only do this if the properties have not been reified, similarly to what is done in JSObject::putInlineSlow(). * bindings/scripts/CodeGeneratorJS.pm: (ConstructorShouldBeOnInstance): Add a FIXME comment indicating that window.constructor should be on the prototype as per the Web IDL specification. (GenerateAttributesHashTable): - Mark 'constructor' property as configurable for Window, as per the specification and consistently with other 'constructor' properties: http://www.w3.org/TR/WebIDL/#interface-prototype-object - Mark properties as configurable even though they are on the instance. Window has its properties on the instance as per the specification: 1. http://heycam.github.io/webidl/#es-attributes 2. http://heycam.github.io/webidl/#PrimaryGlobal (window is [PrimaryGlobal] However, these properties should be configurable as long as they are not marked as [Unforgeable], as per 1. * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: * bindings/scripts/test/JS/JSTestException.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: Rebaseline bindings tests. LayoutTests: * fast/dom/Window/window-properties-configurable-expected.txt: Added. * fast/dom/Window/window-properties-configurable.html: Added. Add a test to check that Window properties are reported as configurable unless the [Unforgeable] ones and that deleting them actually works. * fast/dom/global-constructors.html: Update test so it no longer expects window.Node to be shadowable. As per the specification, the "Node" property is on the window instance, not its prototype. Therefore, it should cannot be shadowed and setting it to something actually overwites the previous value, given that the property is writable as per: - http://heycam.github.io/webidl/#es-interfaces I have verified that the new behavior is consistent with Firefox. * http/tests/security/cross-origin-reified-window-property-access-expected.txt: Added. * http/tests/security/cross-origin-reified-window-property-access.html: Added. * http/tests/security/resources/reify-window.html: Added. Add a test case to cover cross-origin access of Window properties after reification. * js/getOwnPropertyDescriptor-unforgeable-attributes-expected.txt: * js/getOwnPropertyDescriptor-unforgeable-attributes.html: Drop window.self from the list of unforgeable attributes. This attribute is not unforgeable in our implementation or in the specification: - https://html.spec.whatwg.org/multipage/browsers.html#the-window-object * js/getOwnPropertyDescriptor-window-attributes-expected.txt: * js/getOwnPropertyDescriptor-window-attributes.html: - Add coverage for window.self which is a regular Window property. - Add coverage for window.Node which is a constructor property - Add coverage for window.constructor. It should really be on the prototype as per the specification but this at least checks that the property is configurable, as per the specification. - Rebaseline the test as more checks are passing now that Window properties are marked as configurable. Canonical link: https://commits.webkit.org/172180@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@196374 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-02-10 19:47:10 +00:00
PASS descriptor.enumerable is false
PASS descriptor.writable is true
PASS descriptor.configurable is true
PASS descriptor.value is window.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