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

Changeset 203539 in webkit


Ignore:
Timestamp:
Jul 21, 2016, 4:52:35 PM (10 years ago)
Author:
Chris Dumez
Message:

Make parameters to Document.getElementsBy*() operations mandatory
​https://bugs.webkit.org/show_bug.cgi?id=160050

Reviewed by Daniel Bates.

LayoutTests/imported/w3c:

Rebaseline several W3C tests now that more checks are passing.

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

Source/WebCore:

Make parameters to Document.getElementsBy*() operations mandatory to
match the specification:

Firefox and Chrome agree with the specification so the compatibility
risk should be low.

It makes very little sense to call these operations without parameter,
especially considering WebKit uses the string "undefined" if the
parameter is omitted.

No new tests, rebaselined existing tests.

  • dom/Document.idl:

LayoutTests:

Drop cases that were calling the operation without parameter.

  • fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt:
  • fast/dom/getElementsByClassName/dumpHTMLCollection.html:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r203538 r203539  
     12016-07-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Make parameters to Document.getElementsBy*() operations mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160050
     5
     6        Reviewed by Daniel Bates.
     7
     8        Drop cases that were calling the operation without parameter.
     9
     10        * fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt:
     11        * fast/dom/getElementsByClassName/dumpHTMLCollection.html:
     12
    1132016-07-21  Nan Wang  <n_wang@apple.com>
    214
  • trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection-expected.txt

    r188735 r203539  
    1414length: 0
    1515length: 0
    16 length: 0
    1716[object HTMLDivElement], length: 1
    1817[object HTMLDivElement], [object HTMLParagraphElement], length: 2
    … …  
    2322length: 0
    2423length: 0
    25 length: 0
    2624
  • trunk/LayoutTests/fast/dom/getElementsByClassName/dumpHTMLCollection.html

    r188735 r203539  
    3434        log(document.getElementsByClassName("").dump());
    3535        log(document.getElementsByClassName("onetwo").dump());
    36         log(document.getElementsByClassName().dump());
    3736        log(document.getElementsByClassName(null).dump());
    3837        log(document.getElementsByClassName(undefined).dump());
    … …  
    4443        log(elm.getElementsByClassName("").dump());
    4544        log(elm.getElementsByClassName("onetwo").dump());
    46         log(elm.getElementsByClassName().dump());
    4745        log(elm.getElementsByClassName(null).dump());
    4846        log(elm.getElementsByClassName(undefined).dump());
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r203535 r203539  
     12016-07-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Make parameters to Document.getElementsBy*() operations mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160050
     5
     6        Reviewed by Daniel Bates.
     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/html/dom/interfaces-expected.txt:
     12
    1132016-07-21  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt

    r203535 r203539  
    256256PASS Document interface: attribute doctype
    257257PASS Document interface: attribute documentElement
    258 FAIL Document interface: operation getElementsByTagName(DOMString) assert_equals: property has wrong .length expected 1 but got 0
    259 FAIL Document interface: operation getElementsByTagNameNS(DOMString,DOMString) assert_equals: property has wrong .length expected 2 but got 0
    260 FAIL Document interface: operation getElementsByClassName(DOMString) assert_equals: property has wrong .length expected 1 but got 0
     258PASS Document interface: operation getElementsByTagName(DOMString)
     259PASS Document interface: operation getElementsByTagNameNS(DOMString,DOMString)
     260PASS Document interface: operation getElementsByClassName(DOMString)
    261261PASS Document interface: operation createElement(DOMString,ElementCreationOptions)
    262262PASS Document interface: operation createElementNS(DOMString,DOMString,ElementCreationOptions)
    … …  
    296296PASS Document interface: new Document() must inherit property "documentElement" with the proper type (10)
    297297PASS Document interface: new Document() must inherit property "getElementsByTagName" with the proper type (11)
    298 FAIL Document interface: calling getElementsByTagName(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    299             fn.apply(obj, args);
    300         }" did not throw
     298PASS Document interface: calling getElementsByTagName(DOMString) on new Document() with too few arguments must throw TypeError
    301299PASS Document interface: new Document() must inherit property "getElementsByTagNameNS" with the proper type (12)
    302 FAIL Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    303             fn.apply(obj, args);
    304         }" did not throw
     300PASS Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError
    305301PASS Document interface: new Document() must inherit property "getElementsByClassName" with the proper type (13)
    306 FAIL Document interface: calling getElementsByClassName(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    307             fn.apply(obj, args);
    308         }" did not throw
     302PASS Document interface: calling getElementsByClassName(DOMString) on new Document() with too few arguments must throw TypeError
    309303PASS Document interface: new Document() must inherit property "createElement" with the proper type (14)
    310304PASS Document interface: calling createElement(DOMString,ElementCreationOptions) on new Document() with too few arguments must throw TypeError
    … …  
    450444PASS Document interface: xmlDoc must inherit property "documentElement" with the proper type (10)
    451445PASS Document interface: xmlDoc must inherit property "getElementsByTagName" with the proper type (11)
    452 FAIL Document interface: calling getElementsByTagName(DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    453             fn.apply(obj, args);
    454         }" did not throw
     446PASS Document interface: calling getElementsByTagName(DOMString) on xmlDoc with too few arguments must throw TypeError
    455447PASS Document interface: xmlDoc must inherit property "getElementsByTagNameNS" with the proper type (12)
    456 FAIL Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    457             fn.apply(obj, args);
    458         }" did not throw
     448PASS Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on xmlDoc with too few arguments must throw TypeError
    459449PASS Document interface: xmlDoc must inherit property "getElementsByClassName" with the proper type (13)
    460 FAIL Document interface: calling getElementsByClassName(DOMString) on xmlDoc with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    461             fn.apply(obj, args);
    462         }" did not throw
     450PASS Document interface: calling getElementsByClassName(DOMString) on xmlDoc with too few arguments must throw TypeError
    463451PASS Document interface: xmlDoc must inherit property "createElement" with the proper type (14)
    464452PASS Document interface: calling createElement(DOMString,ElementCreationOptions) on xmlDoc with too few arguments must throw TypeError
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt

    r203535 r203539  
    2929PASS Document interface: attribute forms
    3030FAIL Document interface: attribute scripts assert_true: The prototype object must have a property "scripts" expected true got false
    31 FAIL Document interface: operation getElementsByName(DOMString) assert_equals: property has wrong .length expected 1 but got 0
     31PASS Document interface: operation getElementsByName(DOMString)
    3232FAIL Document interface: attribute cssElementMap assert_true: The prototype object must have a property "cssElementMap" expected true got false
    3333PASS Document interface: attribute currentScript
    … …  
    136136PASS Document interface: iframe.contentDocument must inherit property "documentElement" with the proper type (10)
    137137PASS Document interface: iframe.contentDocument must inherit property "getElementsByTagName" with the proper type (11)
    138 FAIL Document interface: calling getElementsByTagName(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    139             fn.apply(obj, args);
    140         }" did not throw
     138PASS Document interface: calling getElementsByTagName(DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    141139PASS Document interface: iframe.contentDocument must inherit property "getElementsByTagNameNS" with the proper type (12)
    142 FAIL Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    143             fn.apply(obj, args);
    144         }" did not throw
     140PASS Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    145141PASS Document interface: iframe.contentDocument must inherit property "getElementsByClassName" with the proper type (13)
    146 FAIL Document interface: calling getElementsByClassName(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    147             fn.apply(obj, args);
    148         }" did not throw
     142PASS Document interface: calling getElementsByClassName(DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    149143PASS Document interface: iframe.contentDocument must inherit property "createElement" with the proper type (14)
    150144PASS Document interface: calling createElement(DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    … …  
    199193PASS Document interface: iframe.contentDocument must inherit property "scripts" with the proper type (50)
    200194PASS Document interface: iframe.contentDocument must inherit property "getElementsByName" with the proper type (51)
    201 FAIL Document interface: calling getElementsByName(DOMString) on iframe.contentDocument with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    202             fn.apply(obj, args);
    203         }" did not throw
     195PASS Document interface: calling getElementsByName(DOMString) on iframe.contentDocument with too few arguments must throw TypeError
    204196FAIL Document interface: iframe.contentDocument must inherit property "cssElementMap" with the proper type (52) assert_inherits: property "cssElementMap" not found in prototype chain
    205197PASS Document interface: iframe.contentDocument must inherit property "currentScript" with the proper type (53)
    … …  
    426418PASS Document interface: new Document() must inherit property "documentElement" with the proper type (10)
    427419PASS Document interface: new Document() must inherit property "getElementsByTagName" with the proper type (11)
    428 FAIL Document interface: calling getElementsByTagName(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    429             fn.apply(obj, args);
    430         }" did not throw
     420PASS Document interface: calling getElementsByTagName(DOMString) on new Document() with too few arguments must throw TypeError
    431421PASS Document interface: new Document() must inherit property "getElementsByTagNameNS" with the proper type (12)
    432 FAIL Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    433             fn.apply(obj, args);
    434         }" did not throw
     422PASS Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on new Document() with too few arguments must throw TypeError
    435423PASS Document interface: new Document() must inherit property "getElementsByClassName" with the proper type (13)
    436 FAIL Document interface: calling getElementsByClassName(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    437             fn.apply(obj, args);
    438         }" did not throw
     424PASS Document interface: calling getElementsByClassName(DOMString) on new Document() with too few arguments must throw TypeError
    439425PASS Document interface: new Document() must inherit property "createElement" with the proper type (14)
    440426PASS Document interface: calling createElement(DOMString) on new Document() with too few arguments must throw TypeError
    … …  
    489475FAIL Document interface: new Document() must inherit property "scripts" with the proper type (50) assert_inherits: property "scripts" not found in prototype chain
    490476PASS Document interface: new Document() must inherit property "getElementsByName" with the proper type (51)
    491 FAIL Document interface: calling getElementsByName(DOMString) on new Document() with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    492             fn.apply(obj, args);
    493         }" did not throw
     477PASS Document interface: calling getElementsByName(DOMString) on new Document() with too few arguments must throw TypeError
    494478FAIL Document interface: new Document() must inherit property "cssElementMap" with the proper type (52) assert_inherits: property "cssElementMap" not found in prototype chain
    495479PASS Document interface: new Document() must inherit property "currentScript" with the proper type (53)
    … …  
    719703PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "documentElement" with the proper type (10)
    720704PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "getElementsByTagName" with the proper type (11)
    721 FAIL Document interface: calling getElementsByTagName(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    722             fn.apply(obj, args);
    723         }" did not throw
     705PASS Document interface: calling getElementsByTagName(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    724706PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "getElementsByTagNameNS" with the proper type (12)
    725 FAIL Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    726             fn.apply(obj, args);
    727         }" did not throw
     707PASS Document interface: calling getElementsByTagNameNS(DOMString,DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    728708PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "getElementsByClassName" with the proper type (13)
    729 FAIL Document interface: calling getElementsByClassName(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    730             fn.apply(obj, args);
    731         }" did not throw
     709PASS Document interface: calling getElementsByClassName(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    732710PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "createElement" with the proper type (14)
    733711PASS Document interface: calling createElement(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    … …  
    782760FAIL Document interface: document.implementation.createDocument(null, "", null) must inherit property "scripts" with the proper type (50) assert_inherits: property "scripts" not found in prototype chain
    783761PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "getElementsByName" with the proper type (51)
    784 FAIL Document interface: calling getElementsByName(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
    785             fn.apply(obj, args);
    786         }" did not throw
     762PASS Document interface: calling getElementsByName(DOMString) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError
    787763FAIL Document interface: document.implementation.createDocument(null, "", null) must inherit property "cssElementMap" with the proper type (52) assert_inherits: property "cssElementMap" not found in prototype chain
    788764PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "currentScript" with the proper type (53)
  • trunk/Source/WebCore/ChangeLog

    r203538 r203539  
     12016-07-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Make parameters to Document.getElementsBy*() operations mandatory
     4        https://bugs.webkit.org/show_bug.cgi?id=160050
     5
     6        Reviewed by Daniel Bates.
     7
     8        Make parameters to Document.getElementsBy*() operations mandatory to
     9        match the specification:
     10        - https://dom.spec.whatwg.org/#interface-document
     11
     12        Firefox and Chrome agree with the specification so the compatibility
     13        risk should be low.
     14
     15        It makes very little sense to call these operations without parameter,
     16        especially considering WebKit uses the string "undefined" if the
     17        parameter is omitted.
     18
     19        No new tests, rebaselined existing tests.
     20
     21        * dom/Document.idl:
     22
    1232016-07-21  Nan Wang  <n_wang@apple.com>
    224
  • trunk/Source/WebCore/dom/Document.idl

    r203535 r203539  
    4949    [ImplementedAs=getElementsByTagNameForObjC] NodeList getElementsByTagName(optional DOMString tagname);
    5050#else
    51     // FIXME: Using "undefined" as default parameter value is wrong.
    52     HTMLCollection getElementsByTagName(optional DOMString tagname = "undefined");
     51    HTMLCollection getElementsByTagName(DOMString tagname);
    5352#endif
    5453
    … …  
    6362    [ObjCLegacyUnnamedParameters, ImplementedAs=getElementsByTagNameNSForObjC] NodeList getElementsByTagNameNS(optional DOMString namespaceURI, optional DOMString localName);
    6463#else
    65     // FIXME: Using "undefined" as default parameter value is wrong.
    66     HTMLCollection getElementsByTagNameNS(optional DOMString? namespaceURI = null, optional DOMString localName = "undefined");
     64    HTMLCollection getElementsByTagNameNS(DOMString? namespaceURI, DOMString localName);
    6765#endif
    6866
    … …  
    187185    readonly attribute DOMString lastModified;
    188186
    189     // FIXME: Using "undefined" as default parameter value is wrong.
    190     NodeList getElementsByName([AtomicString] optional DOMString elementName = "undefined");
     187    NodeList getElementsByName([AtomicString] DOMString elementName);
    191188
    192189#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
    … …  
    245242    [ImplementedAs=getElementsByClassNameForObjC] NodeList getElementsByClassName(optional DOMString classNames);
    246243#else
    247     // FIXME: Using "undefined" as default parameter value is wrong.
    248     HTMLCollection getElementsByClassName(optional DOMString classNames = "undefined");
     244    HTMLCollection getElementsByClassName(DOMString classNames);
    249245#endif
    250246
Note: See TracChangeset for help on using the changeset viewer.