⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 269481 in webkit


Ignore:
Timestamp:
Nov 5, 2020, 3:27:47 PM (6 years ago)
Author:
Chris Dumez
Message:

Add implementation for Object.getOwnPropertyNames() on HTMLDocument
​https://bugs.webkit.org/show_bug.cgi?id=218625

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline test now that more checks are passing. The checks we are failing are failing
in Blink & Gecko also. The checks are are now passing are also passing in Blink & Gecko.

  • web-platform-tests/html/dom/documents/dom-tree-accessors/nameditem-names-expected.txt:

Source/WebCore:

Add implementation for Object.getOwnPropertyNames() on HTMLDocument so that it properly
returns names of the properties that would be returned by the named property getter.
This aligns our behavior with Blink and Gecko.

No new tests, rebaselined existing test.

  • dom/TreeScopeOrderedMap.cpp:

(WebCore::TreeScopeOrderedMap::keys const):

  • dom/TreeScopeOrderedMap.h:
  • html/HTMLDocument.cpp:

(WebCore::HTMLDocument::supportedPropertyNames const):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r269477 r269481  
     12020-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Add implementation for Object.getOwnPropertyNames() on HTMLDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=218625
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Rebaseline test now that more checks are passing. The checks we are failing are failing
     9        in Blink & Gecko also. The checks are are now passing are also passing in Blink & Gecko.
     10
     11        * web-platform-tests/html/dom/documents/dom-tree-accessors/nameditem-names-expected.txt:
     12
    1132020-11-05  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/nameditem-names-expected.txt

    r267646 r269481  
    11
    2 FAIL An embed name appears in a document's property names if the embed is exposed. assert_true: expected true got false
    3 PASS An embed name does not appears in a document's property names if the embed is inside another embed.
    4 FAIL A form name appears in a document's property names. assert_true: expected true got false
    5 FAIL An iframe name appears in a document's property names. assert_true: expected true got false
    6 FAIL An img name appears in a document's property names when the img has no id. assert_true: expected true got false
     2PASS An embed name appears in a document's property names if the embed is exposed.
     3FAIL An embed name does not appears in a document's property names if the embed is inside another embed. assert_false: expected false got true
     4PASS A form name appears in a document's property names.
     5PASS An iframe name appears in a document's property names.
     6PASS An img name appears in a document's property names when the img has no id.
    77FAIL An object name appears in a document's property names if the object is exposed. assert_true: expected true got false
    88FAIL An object id appears in a document's property names if the object is exposed. assert_true: expected true got false
    9 PASS An object name does not appear in a document's property names if the object is inside another object.
    10 PASS An object id does not appear in a document's property names if the object is inside another object.
    11 FAIL An img name appears in a document's property names when the img has an id. assert_true: expected true got false
    12 FAIL An img id appears in a document's property names when the img has a name. assert_true: expected true got false
     9FAIL An object name does not appear in a document's property names if the object is inside another object. assert_false: expected false got true
     10FAIL An object id does not appear in a document's property names if the object is inside another object. assert_false: expected false got true
     11PASS An img name appears in a document's property names when the img has an id.
     12PASS An img id appears in a document's property names when the img has a name.
    1313PASS An img id does not appear in a document's property names when the img has no name.
    14 FAIL A document's property names can include integer strings. assert_true: expected true got false
     14PASS A document's property names can include integer strings.
    1515PASS A template name does not appear in a document's property names.
    1616PASS An img name does not appear in a document's property names when the img is in a template's document fragment.
    17 FAIL A document's property names appear in tree order. assert_equals: expected 0 but got -1
     17FAIL A document's property names appear in tree order. assert_greater_than: expected a number greater than 5 but got 0
    1818
  • trunk/Source/WebCore/ChangeLog

    r269477 r269481  
     12020-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Add implementation for Object.getOwnPropertyNames() on HTMLDocument
     4        https://bugs.webkit.org/show_bug.cgi?id=218625
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add implementation for Object.getOwnPropertyNames() on HTMLDocument so that it properly
     9        returns names of the properties that would be returned by the named property getter.
     10        This aligns our behavior with Blink and Gecko.
     11
     12        No new tests, rebaselined existing test.
     13
     14        * dom/TreeScopeOrderedMap.cpp:
     15        (WebCore::TreeScopeOrderedMap::keys const):
     16        * dom/TreeScopeOrderedMap.h:
     17        * html/HTMLDocument.cpp:
     18        (WebCore::HTMLDocument::supportedPropertyNames const):
     19
    1202020-11-05  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Source/WebCore/dom/TreeScopeOrderedMap.cpp

    r259990 r269481  
    217217}
    218218
     219const Vector<AtomString> TreeScopeOrderedMap::keys() const
     220{
     221    Vector<AtomString> result;
     222    result.reserveInitialCapacity(m_map.size());
     223    for (auto* key : m_map.keys())
     224        result.uncheckedAppend(const_cast<AtomStringImpl*>(key));
     225    return result;
     226}
     227
    219228} // namespace WebCore
  • trunk/Source/WebCore/dom/TreeScopeOrderedMap.h

    r254087 r269481  
    6666    const Vector<Element*>* getAllElementsById(const AtomStringImpl&, const TreeScope&) const;
    6767
     68    const Vector<AtomString> keys() const;
     69
    6870private:
    6971    template <typename KeyMatchingFunction>
  • trunk/Source/WebCore/html/HTMLDocument.cpp

    r268114 r269481  
    141141Vector<AtomString> HTMLDocument::supportedPropertyNames() const
    142142{
    143     // https://html.spec.whatwg.org/multipage/dom.html#dom-document-namedItem-which
    144     //
    145     // ... The supported property names of a Document object document at any moment consist of the following, in
    146     // tree order according to the element that contributed them, ignoring later duplicates, and with values from
    147     // id attributes coming before values from name attributes when the same element contributes both:
    148     //
    149     // - the value of the name content attribute for all applet, exposed embed, form, iframe, img, and exposed
    150     //   object elements that have a non-empty name content attribute and are in a document tree with document
    151     //   as their root;
    152     // - the value of the id content attribute for all applet and exposed object elements that have a non-empty
    153     //   id content attribute and are in a document tree with document as their root; and
    154     // - the value of the id content attribute for all img elements that have both a non-empty id content attribute
    155     //   and a non-empty name content attribute, and are in a document tree with document as their root.
    156 
    157     // FIXME: Implement.
    158     return { };
     143    auto properties = m_documentNamedItem.keys();
     144    // The specification says these should be sorted in document order but this would be expensive
     145    // and other browser engines do not comply with this part of the specification. For now, just
     146    // do an alphabetical sort to get consistent results.
     147    std::sort(properties.begin(), properties.end(), WTF::codePointCompareLessThan);
     148    return properties;
    159149}
    160150
Note: See TracChangeset for help on using the changeset viewer.