Changeset 203852 in webkit


Ignore:
Timestamp:
Jul 28, 2016 6:19:41 PM (8 years ago)
Author:
Chris Dumez
Message:

Add support for Element.getAttributeNames()
https://bugs.webkit.org/show_bug.cgi?id=160327

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline several W3C tests now that more checks are passing.

  • web-platform-tests/dom/interfaces-expected.txt:
  • web-platform-tests/dom/nodes/attributes-expected.txt:
  • web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Add support for Element.getAttributeNames():

Firefox already supports this, Chrome 52 does not yet.

Test: fast/dom/Element/getAttributeNames.html

  • bindings/js/JSDOMBinding.h:

(WebCore::JSValueTraits<AtomicString>::arrayJSValue):

  • dom/Element.cpp:

(WebCore::Element::getAttributeNames):

  • dom/Element.h:
  • dom/Element.idl:

LayoutTests:

Add layout test coverage. I have verified that this test is passing in
Firefox 47.

  • fast/dom/Element/getAttributeNames-expected.txt: Added.
  • fast/dom/Element/getAttributeNames.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203849 r203852  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for Element.getAttributeNames()
     4        https://bugs.webkit.org/show_bug.cgi?id=160327
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add layout test coverage. I have verified that this test is passing in
     9        Firefox 47.
     10
     11        * fast/dom/Element/getAttributeNames-expected.txt: Added.
     12        * fast/dom/Element/getAttributeNames.html: Added.
     13
    1142016-07-28  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r203849 r203852  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for Element.getAttributeNames()
     4        https://bugs.webkit.org/show_bug.cgi?id=160327
     5
     6        Reviewed by Alex Christensen.
     7
     8        Rebaseline several W3C tests now that more checks are passing.
     9
     10        * web-platform-tests/dom/interfaces-expected.txt:
     11        * web-platform-tests/dom/nodes/attributes-expected.txt:
     12        * web-platform-tests/html/dom/interfaces-expected.txt:
     13
    1142016-07-28  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt

    r203848 r203852  
    743743PASS Element interface: operation hasAttributes()
    744744PASS Element interface: attribute attributes
    745 FAIL Element interface: operation getAttributeNames() assert_own_property: interface prototype object missing non-static operation expected property "getAttributeNames" missing
     745PASS Element interface: operation getAttributeNames()
    746746PASS Element interface: operation getAttribute(DOMString)
    747747PASS Element interface: operation getAttributeNS(DOMString,DOMString)
     
    794794PASS Element interface: element must inherit property "hasAttributes" with the proper type (8)
    795795PASS Element interface: element must inherit property "attributes" with the proper type (9)
    796 FAIL Element interface: element must inherit property "getAttributeNames" with the proper type (10) assert_inherits: property "getAttributeNames" not found in prototype chain
     796PASS Element interface: element must inherit property "getAttributeNames" with the proper type (10)
    797797PASS Element interface: element must inherit property "getAttribute" with the proper type (11)
    798798PASS Element interface: calling getAttribute(DOMString) on element with too few arguments must throw TypeError
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/attributes-expected.txt

    r200309 r203852  
    4949PASS setAttributeNode, if it fires mutation events, should fire one with the new node when resetting an existing attribute (outer shell)
    5050PASS setAttributeNode called with an Attr that has the same name as an existing one should not change attribute order
    51 FAIL getAttributeNames tests el.getAttributeNames is not a function. (In 'el.getAttributeNames()', 'el.getAttributeNames' is undefined)
     51PASS getAttributeNames tests
    5252FAIL Own property correctness with basic attributes assert_array_equals: lengths differ, expected 4 got 2
    5353FAIL Own property correctness with non-namespaced attribute before same-name namespaced one assert_array_equals: lengths differ, expected 5 got 3
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt

    r203849 r203852  
    11501150PASS Element interface: document.createElement("noscript") must inherit property "hasAttributes" with the proper type (7)
    11511151PASS Element interface: document.createElement("noscript") must inherit property "attributes" with the proper type (8)
    1152 FAIL Element interface: document.createElement("noscript") must inherit property "getAttributeNames" with the proper type (9) assert_inherits: property "getAttributeNames" not found in prototype chain
     1152PASS Element interface: document.createElement("noscript") must inherit property "getAttributeNames" with the proper type (9)
    11531153PASS Element interface: document.createElement("noscript") must inherit property "getAttribute" with the proper type (10)
    11541154PASS Element interface: calling getAttribute(DOMString) on document.createElement("noscript") with too few arguments must throw TypeError
  • trunk/Source/WebCore/ChangeLog

    r203849 r203852  
     12016-07-28  Chris Dumez  <cdumez@apple.com>
     2
     3        Add support for Element.getAttributeNames()
     4        https://bugs.webkit.org/show_bug.cgi?id=160327
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add support for Element.getAttributeNames():
     9        - https://dom.spec.whatwg.org/#dom-element-getattributenames
     10
     11        Firefox already supports this, Chrome 52 does not yet.
     12
     13        Test: fast/dom/Element/getAttributeNames.html
     14
     15        * bindings/js/JSDOMBinding.h:
     16        (WebCore::JSValueTraits<AtomicString>::arrayJSValue):
     17        * dom/Element.cpp:
     18        (WebCore::Element::getAttributeNames):
     19        * dom/Element.h:
     20        * dom/Element.idl:
     21
    1222016-07-28  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/dom/Element.cpp

    r203324 r203852  
    499499}
    500500
     501Vector<String> Element::getAttributeNames() const
     502{
     503    Vector<String> attributesVector;
     504    if (!hasAttributes())
     505        return attributesVector;
     506
     507    auto attributes = attributesIterator();
     508    attributesVector.reserveInitialCapacity(attributes.attributeCount());
     509    for (auto& attribute : attributes)
     510        attributesVector.uncheckedAppend(attribute.name().toString());
     511    return attributesVector;
     512}
     513
    501514bool Element::isFocusable() const
    502515{
  • trunk/Source/WebCore/dom/Element.h

    r203383 r203852  
    7878    void setSynchronizedLazyAttribute(const QualifiedName&, const AtomicString& value);
    7979    bool removeAttribute(const QualifiedName&);
     80    Vector<String> getAttributeNames() const;
    8081
    8182    // Typed getters and setters for language bindings.
  • trunk/Source/WebCore/dom/Element.idl

    r203547 r203852  
    119119    void scrollIntoView(optional boolean alignWithTop = true);
    120120
     121    sequence<DOMString> getAttributeNames();
     122
    121123    // WebKit extensions
    122124
Note: See TracChangeset for help on using the changeset viewer.