Make our bindings' GetOwnPropertySlot() behave according to specification
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 19:15:44 +0000 (19:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Aug 2015 19:15:44 +0000 (19:15 +0000)
commit1485c01c19807d560ae07e662923c713eaf2d82b
tree16c043d2390399ecdbd83d0a44ec742aeb16434f
parente453f074a951245d5222856c1d3ee7f5177fdd05
Make our bindings' GetOwnPropertySlot() behave according to specification
https://bugs.webkit.org/show_bug.cgi?id=148092

Reviewed by Geoffrey Garen.

Source/WebCore:

Make our bindings' GetOwnPropertySlot() behave according to
specification. In particular, our bindings use to do:
1. Indexed getter
2. Check static properties
3. Prototype check
4. Named getter
5. Check own properties

According to the specification [1][2], we should do:
- If the interface has [OverrideBuiltins]:
    1. Indexed getter
    2. Named getter
    3. Static / own properties
- Otherwise:
    1. Indexed getter
    2. Static / own properties
    3. Prototype check
    4. Named getter

This patch adds support for the [OverrideBuiltins] IDL extended
attribute [3] and aligns our bindings implementation with the Web IDL
specification weither that IDL extended attribute is present or
not.

[1] https://heycam.github.io/webidl/#getownproperty-guts
[2] https://heycam.github.io/webidl/#dfn-named-property-visibility
[3] https://heycam.github.io/webidl/#OverrideBuiltins

Performance:
- PerformanceTests/Bindings/childNodes-traversal.html: ~Same
- PerformanceTests/Bindings/children-traversal.html: +104% :)

No new tests, covered by:
fast/dom/htmlcollection-getownproperty.html
fast/dom/collection-length-should-not-be-overridden.html
fast/forms/input-named-action-overrides-action-attribute.html

* bindings/js/JSHTMLCollectionCustom.cpp:
(WebCore::JSHTMLCollection::nameGetter):
Add assertions to make sure we don't use HTMLCollection's namedGetter()
for HTMLFormControlsCollection / HTMLOptionsCollection subclasses.
We should use the subclasses' namedGetter() instead.

* bindings/js/JSHTMLOptionsCollectionCustom.cpp:
(WebCore::JSHTMLOptionsCollection::canGetItemsForName):
(WebCore::JSHTMLOptionsCollection::nameGetter):
Add code for handling named getter requests on
HTMLOptionsCollection.

* bindings/js/JSNodeListCustom.cpp:
(WebCore::JSNodeList::canGetItemsForName):
(WebCore::JSNodeList::nameGetter):
Refactor custom code for the NodeList named getter, now that the
IDL interface is using [CustomNamedGetter] instead of
[JSCustomGetOwnPropertySlotAndDescriptor].

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateGetOwnPropertySlotBody):
(GenerateHeaderContentHeader): Deleted.
- Add support for the [OverrideBuiltins] IDL extended attribute and
update the generated getOwnPropertySlot() methods to match the
Web IDL specification.
- Also drop the JSC::HasImpureGetOwnPropertySlot flag for interfaces
that have a named getter but NOT the [OverrideBuiltins] IDL extended
attribute. Without [OverrideBuiltins], named properties can no longer
shadow own properties so we no longer need to mark GetOwnPropertySlot
as impure. This allows caching of properties.

* bindings/scripts/IDLAttributes.txt:
Add [OverrideBuiltins] IDL extended attribute [3].

* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
(WebCore::JSTestActiveDOMObject::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
(WebCore::JSTestCustomNamedGetter::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
(WebCore::JSTestEventTarget::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestException.cpp:
(WebCore::JSTestException::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterface::getOwnPropertySlot):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObj::getOwnPropertySlot):
Rebaseline the bindings tests as their getOwnPropertySlot() method
is now different.

* bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp: Added.
* bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h: Added.
* bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h: Added.
* bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp: Added.
* bindings/scripts/test/JS/JSTestOverrideBuiltins.h: Added.
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
* bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h: Added.
* bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm: Added.
* bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h: Added.
* bindings/scripts/test/TestOverrideBuiltins.idl: Added.
Add bindings test coverage for the new [OverrideBuiltins] IDL extended
attribute [3].

* dom/DOMStringMap.idl:
Add [OverrideBuiltins] IDL extended attribute to match the specification:
https://html.spec.whatwg.org/multipage/infrastructure.html#domstringmap

* dom/NodeList.idl:
Use CustomNamedGetter IDL extended attribute instead of
JSCustomGetOwnPropertySlotAndDescriptor as NodeList merely implements
a custom named getter. This makes sure that the order in which the
named getter is called is correct as per the Web IDL specification.

* html/HTMLDocument.idl:
Add [OverrideBuiltins] IDL extended attribute to match the specification:
https://html.spec.whatwg.org/multipage/dom.html#the-document-object

* html/HTMLFormElement.idl:
Add [OverrideBuiltins] IDL extended attribute to match the specification:
https://html.spec.whatwg.org/multipage/forms.html#the-form-element

* html/HTMLOptionsCollection.idl:
Add missing 'getter' in front of the named getter, as the per the HTML
specification. Without this, HTMLOptionsCollection would not be
recognized as a named properties object, which means that we would not
check the HTMLOptionsCollection prototype before querying the named
getter on HTMLCollection. This used to work because the bindings
generator was hard-coding the prototype check for every HTML*Collection
IDL interface. In this patch, we generalized the check to every
interface that has a named getter.

LayoutTests:

* fast/dom/childnode-item-after-itemname.html:
Update the test so the item's id in the NodeList is "testItem"
instead of "item". NodeList has a method called item() which now
takes priority over the name when accessing Nodelist.item, as per
the Web IDL specification.

* fast/dom/htmlcollection-getownproperty-expected.txt:
Rebaseline test. This is a progression.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188590 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/childnode-item-after-itemname.html
LayoutTests/fast/dom/htmlcollection-getownproperty-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp
Source/WebCore/bindings/js/JSHTMLOptionsCollectionCustom.cpp
Source/WebCore/bindings/js/JSNodeListCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltins.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestOverrideBuiltinsPrivate.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.h
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.h
Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltins.mm [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/ObjC/DOMTestOverrideBuiltinsInternal.h [new file with mode: 0644]
Source/WebCore/bindings/scripts/test/TestOverrideBuiltins.idl [new file with mode: 0644]
Source/WebCore/dom/DOMStringMap.idl
Source/WebCore/dom/NodeList.idl
Source/WebCore/html/HTMLDocument.idl
Source/WebCore/html/HTMLFormElement.idl
Source/WebCore/html/HTMLOptionsCollection.idl