Object.getOwnPropertyNames() does not return named properties
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Sep 2015 17:43:49 +0000 (17:43 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Sep 2015 17:43:49 +0000 (17:43 +0000)
commit73a7e8b599dde7e7179d7123738c966d0aa63b1a
tree41ccaedab759f502be2c39f6b620fc4ba7299cdb
parent408085592904bec4825ac4dad40ac22723fead3d
Object.getOwnPropertyNames() does not return named properties
https://bugs.webkit.org/show_bug.cgi?id=149562
<rdar://problem/22879779>

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline existing W3C tests now that Object.getOwnPropertyNames()
returns named properties for HTMLCollection. We unfortunately still
don't pass those because 'length' / 'constructor' properties are
currently on the instance and they should be on the prototype.

* web-platform-tests/dom/collections/HTMLCollection-supported-property-names-expected.txt:
* web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt:
* web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt:
* web-platform-tests/html/dom/documents/dom-tree-accessors/document.forms-expected.txt:

Source/WebCore:

Previously, Object.getOwnPropertyNames() did not return named properties
for interfaces with named property getters. This patch adds support for
this in the JS bindings generator and uses it for HTMLCollection only
for now. Other interfaces will be taken care of independently.

Note that currently, even though the named properties are returned by
Object.getOwnPropertyNames(), these properties are still not enumerated.
This is because these are always unenumerable for existing DOM interfaces:
- https://dom.spec.whatwg.org/#interface-htmlcollection
- https://dom.spec.whatwg.org/#namednodemap

In the future, we may need to extend support if some interfaces require
those to be enumerable.

Test: fast/dom/htmlcollection-getownpropertynames.html

* Modules/mediastream/RTCStatsResponse.cpp:
(WebCore::WebCore::RTCStatsResponse::supportedPropertyNames):
* Modules/mediastream/RTCStatsResponse.h:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
* css/StyleSheetList.cpp:
(WebCore::StyleSheetList::supportedPropertyNames):
* css/StyleSheetList.h:
* dom/DOMNamedFlowCollection.cpp:
(WebCore::DOMNamedFlowCollection::supportedPropertyNames):
* dom/DOMNamedFlowCollection.h:
* dom/NamedNodeMap.cpp:
(WebCore::NamedNodeMap::supportedPropertyNames):
* dom/NamedNodeMap.h:
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::supportedPropertyNames):
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::propertyNames):
(WebCore::CollectionNamedElementCache::appendToIdCache):
(WebCore::CollectionNamedElementCache::appendToNameCache):
(WebCore::CollectionNamedElementCache::memoryCost):
(WebCore::CollectionNamedElementCache::append):
* plugins/DOMMimeTypeArray.cpp:
(WebCore::DOMMimeTypeArray::supportedPropertyNames):
* plugins/DOMMimeTypeArray.h:
* plugins/DOMPlugin.cpp:
(WebCore::DOMPlugin::supportedPropertyNames):
* plugins/DOMPlugin.h:
* plugins/DOMPluginArray.cpp:
(WebCore::DOMPluginArray::supportedPropertyNames):
* plugins/DOMPluginArray.h:

LayoutTests:

Add layout test that verifies that Object.getOwnPropertyNames() returns
an HTMLCollection's named properties, in addition to its indexes. It
also checks that they are not enumerable, as per the DOM specification.

* fast/dom/htmlcollection-getownpropertynames-expected.txt: Added.
* fast/dom/htmlcollection-getownpropertynames.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@190280 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/htmlcollection-getownpropertynames-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/htmlcollection-getownpropertynames.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/dom/collections/HTMLCollection-supported-property-names-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-getElementsByTagName-expected.txt
LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-getElementsByTagName-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.forms-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCStatsResponse.cpp
Source/WebCore/Modules/mediastream/RTCStatsResponse.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestOverrideBuiltins.h
Source/WebCore/css/StyleSheetList.cpp
Source/WebCore/css/StyleSheetList.h
Source/WebCore/dom/DOMNamedFlowCollection.cpp
Source/WebCore/dom/DOMNamedFlowCollection.h
Source/WebCore/dom/NamedNodeMap.cpp
Source/WebCore/dom/NamedNodeMap.h
Source/WebCore/html/HTMLCollection.cpp
Source/WebCore/html/HTMLCollection.h
Source/WebCore/plugins/DOMMimeTypeArray.cpp
Source/WebCore/plugins/DOMMimeTypeArray.h
Source/WebCore/plugins/DOMPlugin.cpp
Source/WebCore/plugins/DOMPlugin.h
Source/WebCore/plugins/DOMPluginArray.cpp
Source/WebCore/plugins/DOMPluginArray.h