Changeset 229566 in webkit


Ignore:
Timestamp:
Mar 12, 2018 6:37:23 PM (6 years ago)
Author:
Chris Dumez
Message:

Return boolean from DOMTokenList's replace() method
https://bugs.webkit.org/show_bug.cgi?id=183567

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline web platform test now that all checks are passing.

  • web-platform-tests/dom/nodes/Element-classlist-expected.txt:

Source/WebCore:

Have DOMTokenList's replace() method return a boolean indicating if the
token was replaced, as per:

This is a recent addition to the DOM specification:

No new tests, rebaselined existing test.

  • html/DOMTokenList.cpp:

(WebCore::replaceInOrderedSet):
(WebCore::DOMTokenList::replace):

  • html/DOMTokenList.h:
  • html/DOMTokenList.idl:
Location:
trunk
Files:
6 edited

Legend:

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

    r229559 r229566  
     12018-03-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Return boolean from DOMTokenList's replace() method
     4        https://bugs.webkit.org/show_bug.cgi?id=183567
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Rebaseline web platform test now that all checks are passing.
     9
     10        * web-platform-tests/dom/nodes/Element-classlist-expected.txt:
     11
    1122018-03-12  Ryan Haddad  <ryanhaddad@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist-expected.txt

    r229544 r229566  
    259259PASS classList.replace("b", " a") with attribute value null (HTML node)
    260260PASS classList.replace("b", "a ") with attribute value null (HTML node)
    261 FAIL classList.replace("a", "a") with attribute value "a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    262 FAIL classList.replace("a", "b") with attribute value "a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    263 FAIL classList.replace("A", "b") with attribute value "a" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    264 FAIL classList.replace("b", "A") with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    265 FAIL classList.replace("c", "a") with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    266 FAIL classList.replace("d", "e") with attribute value "a b c" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    267 FAIL classList.replace("a", "a") with attribute value "a a a  b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    268 FAIL classList.replace("c", "d") with attribute value "a a a  b" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    269 FAIL classList.replace("a", "b") with attribute value null (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    270 FAIL classList.replace("a", "b") with attribute value "" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    271 FAIL classList.replace("a", "b") with attribute value " " (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    272 FAIL classList.replace("a", "b") with attribute value " a  \f" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    273 FAIL classList.replace("b", "d") with attribute value "a b c" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    274 FAIL classList.replace("c", "a") with attribute value "a b c" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    275 FAIL classList.replace("c", "a") with attribute value "c b a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    276 FAIL classList.replace("a", "c") with attribute value "a b a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    277 FAIL classList.replace("b", "c") with attribute value "a b a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    278 FAIL classList.replace("a", "c") with attribute value "   a  a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    279 FAIL classList.replace("b", "c") with attribute value "   a  a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    280 FAIL classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    281 FAIL classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    282 FAIL classList.replace(null, "b") with attribute value "a null" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    283 FAIL classList.replace("a", null) with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    284 FAIL classList.replace(undefined, "b") with attribute value "a undefined" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    285 FAIL classList.replace("a", undefined) with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
     261PASS classList.replace("a", "a") with attribute value "a" (HTML node)
     262PASS classList.replace("a", "b") with attribute value "a" (HTML node)
     263PASS classList.replace("A", "b") with attribute value "a" (HTML node)
     264PASS classList.replace("b", "A") with attribute value "a b" (HTML node)
     265PASS classList.replace("c", "a") with attribute value "a b" (HTML node)
     266PASS classList.replace("d", "e") with attribute value "a b c" (HTML node)
     267PASS classList.replace("a", "a") with attribute value "a a a  b" (HTML node)
     268PASS classList.replace("c", "d") with attribute value "a a a  b" (HTML node)
     269PASS classList.replace("a", "b") with attribute value null (HTML node)
     270PASS classList.replace("a", "b") with attribute value "" (HTML node)
     271PASS classList.replace("a", "b") with attribute value " " (HTML node)
     272PASS classList.replace("a", "b") with attribute value " a  \f" (HTML node)
     273PASS classList.replace("b", "d") with attribute value "a b c" (HTML node)
     274PASS classList.replace("c", "a") with attribute value "a b c" (HTML node)
     275PASS classList.replace("c", "a") with attribute value "c b a" (HTML node)
     276PASS classList.replace("a", "c") with attribute value "a b a" (HTML node)
     277PASS classList.replace("b", "c") with attribute value "a b a" (HTML node)
     278PASS classList.replace("a", "c") with attribute value "   a  a b" (HTML node)
     279PASS classList.replace("b", "c") with attribute value "   a  a b" (HTML node)
     280PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (HTML node)
     281PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (HTML node)
     282PASS classList.replace(null, "b") with attribute value "a null" (HTML node)
     283PASS classList.replace("a", null) with attribute value "a b" (HTML node)
     284PASS classList.replace(undefined, "b") with attribute value "a undefined" (HTML node)
     285PASS classList.replace("a", undefined) with attribute value "a b" (HTML node)
    286286PASS Assigning to classList (XHTML node)
    287287PASS .supports() must throw TypeError (XHTML node)
     
    543543PASS classList.replace("b", " a") with attribute value null (XHTML node)
    544544PASS classList.replace("b", "a ") with attribute value null (XHTML node)
    545 FAIL classList.replace("a", "a") with attribute value "a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    546 FAIL classList.replace("a", "b") with attribute value "a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    547 FAIL classList.replace("A", "b") with attribute value "a" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    548 FAIL classList.replace("b", "A") with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    549 FAIL classList.replace("c", "a") with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    550 FAIL classList.replace("d", "e") with attribute value "a b c" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    551 FAIL classList.replace("a", "a") with attribute value "a a a  b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    552 FAIL classList.replace("c", "d") with attribute value "a a a  b" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    553 FAIL classList.replace("a", "b") with attribute value null (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    554 FAIL classList.replace("a", "b") with attribute value "" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    555 FAIL classList.replace("a", "b") with attribute value " " (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    556 FAIL classList.replace("a", "b") with attribute value " a  \f" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    557 FAIL classList.replace("b", "d") with attribute value "a b c" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    558 FAIL classList.replace("c", "a") with attribute value "a b c" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    559 FAIL classList.replace("c", "a") with attribute value "c b a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    560 FAIL classList.replace("a", "c") with attribute value "a b a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    561 FAIL classList.replace("b", "c") with attribute value "a b a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    562 FAIL classList.replace("a", "c") with attribute value "   a  a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    563 FAIL classList.replace("b", "c") with attribute value "   a  a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    564 FAIL classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    565 FAIL classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    566 FAIL classList.replace(null, "b") with attribute value "a null" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    567 FAIL classList.replace("a", null) with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    568 FAIL classList.replace(undefined, "b") with attribute value "a undefined" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    569 FAIL classList.replace("a", undefined) with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
     545PASS classList.replace("a", "a") with attribute value "a" (XHTML node)
     546PASS classList.replace("a", "b") with attribute value "a" (XHTML node)
     547PASS classList.replace("A", "b") with attribute value "a" (XHTML node)
     548PASS classList.replace("b", "A") with attribute value "a b" (XHTML node)
     549PASS classList.replace("c", "a") with attribute value "a b" (XHTML node)
     550PASS classList.replace("d", "e") with attribute value "a b c" (XHTML node)
     551PASS classList.replace("a", "a") with attribute value "a a a  b" (XHTML node)
     552PASS classList.replace("c", "d") with attribute value "a a a  b" (XHTML node)
     553PASS classList.replace("a", "b") with attribute value null (XHTML node)
     554PASS classList.replace("a", "b") with attribute value "" (XHTML node)
     555PASS classList.replace("a", "b") with attribute value " " (XHTML node)
     556PASS classList.replace("a", "b") with attribute value " a  \f" (XHTML node)
     557PASS classList.replace("b", "d") with attribute value "a b c" (XHTML node)
     558PASS classList.replace("c", "a") with attribute value "a b c" (XHTML node)
     559PASS classList.replace("c", "a") with attribute value "c b a" (XHTML node)
     560PASS classList.replace("a", "c") with attribute value "a b a" (XHTML node)
     561PASS classList.replace("b", "c") with attribute value "a b a" (XHTML node)
     562PASS classList.replace("a", "c") with attribute value "   a  a b" (XHTML node)
     563PASS classList.replace("b", "c") with attribute value "   a  a b" (XHTML node)
     564PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XHTML node)
     565PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XHTML node)
     566PASS classList.replace(null, "b") with attribute value "a null" (XHTML node)
     567PASS classList.replace("a", null) with attribute value "a b" (XHTML node)
     568PASS classList.replace(undefined, "b") with attribute value "a undefined" (XHTML node)
     569PASS classList.replace("a", undefined) with attribute value "a b" (XHTML node)
    570570PASS Assigning to classList (MathML node)
    571571PASS .supports() must throw TypeError (MathML node)
     
    827827PASS classList.replace("b", " a") with attribute value null (MathML node)
    828828PASS classList.replace("b", "a ") with attribute value null (MathML node)
    829 FAIL classList.replace("a", "a") with attribute value "a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    830 FAIL classList.replace("a", "b") with attribute value "a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    831 FAIL classList.replace("A", "b") with attribute value "a" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    832 FAIL classList.replace("b", "A") with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    833 FAIL classList.replace("c", "a") with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    834 FAIL classList.replace("d", "e") with attribute value "a b c" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    835 FAIL classList.replace("a", "a") with attribute value "a a a  b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    836 FAIL classList.replace("c", "d") with attribute value "a a a  b" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    837 FAIL classList.replace("a", "b") with attribute value null (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    838 FAIL classList.replace("a", "b") with attribute value "" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    839 FAIL classList.replace("a", "b") with attribute value " " (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    840 FAIL classList.replace("a", "b") with attribute value " a  \f" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    841 FAIL classList.replace("b", "d") with attribute value "a b c" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    842 FAIL classList.replace("c", "a") with attribute value "a b c" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    843 FAIL classList.replace("c", "a") with attribute value "c b a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    844 FAIL classList.replace("a", "c") with attribute value "a b a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    845 FAIL classList.replace("b", "c") with attribute value "a b a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    846 FAIL classList.replace("a", "c") with attribute value "   a  a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    847 FAIL classList.replace("b", "c") with attribute value "   a  a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    848 FAIL classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    849 FAIL classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    850 FAIL classList.replace(null, "b") with attribute value "a null" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    851 FAIL classList.replace("a", null) with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    852 FAIL classList.replace(undefined, "b") with attribute value "a undefined" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    853 FAIL classList.replace("a", undefined) with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
     829PASS classList.replace("a", "a") with attribute value "a" (MathML node)
     830PASS classList.replace("a", "b") with attribute value "a" (MathML node)
     831PASS classList.replace("A", "b") with attribute value "a" (MathML node)
     832PASS classList.replace("b", "A") with attribute value "a b" (MathML node)
     833PASS classList.replace("c", "a") with attribute value "a b" (MathML node)
     834PASS classList.replace("d", "e") with attribute value "a b c" (MathML node)
     835PASS classList.replace("a", "a") with attribute value "a a a  b" (MathML node)
     836PASS classList.replace("c", "d") with attribute value "a a a  b" (MathML node)
     837PASS classList.replace("a", "b") with attribute value null (MathML node)
     838PASS classList.replace("a", "b") with attribute value "" (MathML node)
     839PASS classList.replace("a", "b") with attribute value " " (MathML node)
     840PASS classList.replace("a", "b") with attribute value " a  \f" (MathML node)
     841PASS classList.replace("b", "d") with attribute value "a b c" (MathML node)
     842PASS classList.replace("c", "a") with attribute value "a b c" (MathML node)
     843PASS classList.replace("c", "a") with attribute value "c b a" (MathML node)
     844PASS classList.replace("a", "c") with attribute value "a b a" (MathML node)
     845PASS classList.replace("b", "c") with attribute value "a b a" (MathML node)
     846PASS classList.replace("a", "c") with attribute value "   a  a b" (MathML node)
     847PASS classList.replace("b", "c") with attribute value "   a  a b" (MathML node)
     848PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (MathML node)
     849PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (MathML node)
     850PASS classList.replace(null, "b") with attribute value "a null" (MathML node)
     851PASS classList.replace("a", null) with attribute value "a b" (MathML node)
     852PASS classList.replace(undefined, "b") with attribute value "a undefined" (MathML node)
     853PASS classList.replace("a", undefined) with attribute value "a b" (MathML node)
    854854PASS Assigning to classList (XML node with null namespace)
    855855PASS .supports() must throw TypeError (XML node with null namespace)
     
    11111111PASS classList.replace("b", " a") with attribute value null (XML node with null namespace)
    11121112PASS classList.replace("b", "a ") with attribute value null (XML node with null namespace)
    1113 FAIL classList.replace("a", "a") with attribute value "a" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1114 FAIL classList.replace("a", "b") with attribute value "a" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1115 FAIL classList.replace("A", "b") with attribute value "a" (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1116 FAIL classList.replace("b", "A") with attribute value "a b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1117 FAIL classList.replace("c", "a") with attribute value "a b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1118 FAIL classList.replace("d", "e") with attribute value "a b c" (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1119 FAIL classList.replace("a", "a") with attribute value "a a a  b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1120 FAIL classList.replace("c", "d") with attribute value "a a a  b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1121 FAIL classList.replace("a", "b") with attribute value null (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1122 FAIL classList.replace("a", "b") with attribute value "" (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1123 FAIL classList.replace("a", "b") with attribute value " " (XML node with null namespace) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1124 FAIL classList.replace("a", "b") with attribute value " a  \f" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1125 FAIL classList.replace("b", "d") with attribute value "a b c" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1126 FAIL classList.replace("c", "a") with attribute value "a b c" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1127 FAIL classList.replace("c", "a") with attribute value "c b a" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1128 FAIL classList.replace("a", "c") with attribute value "a b a" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1129 FAIL classList.replace("b", "c") with attribute value "a b a" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1130 FAIL classList.replace("a", "c") with attribute value "   a  a b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1131 FAIL classList.replace("b", "c") with attribute value "   a  a b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1132 FAIL classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1133 FAIL classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1134 FAIL classList.replace(null, "b") with attribute value "a null" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1135 FAIL classList.replace("a", null) with attribute value "a b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1136 FAIL classList.replace(undefined, "b") with attribute value "a undefined" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1137 FAIL classList.replace("a", undefined) with attribute value "a b" (XML node with null namespace) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
     1113PASS classList.replace("a", "a") with attribute value "a" (XML node with null namespace)
     1114PASS classList.replace("a", "b") with attribute value "a" (XML node with null namespace)
     1115PASS classList.replace("A", "b") with attribute value "a" (XML node with null namespace)
     1116PASS classList.replace("b", "A") with attribute value "a b" (XML node with null namespace)
     1117PASS classList.replace("c", "a") with attribute value "a b" (XML node with null namespace)
     1118PASS classList.replace("d", "e") with attribute value "a b c" (XML node with null namespace)
     1119PASS classList.replace("a", "a") with attribute value "a a a  b" (XML node with null namespace)
     1120PASS classList.replace("c", "d") with attribute value "a a a  b" (XML node with null namespace)
     1121PASS classList.replace("a", "b") with attribute value null (XML node with null namespace)
     1122PASS classList.replace("a", "b") with attribute value "" (XML node with null namespace)
     1123PASS classList.replace("a", "b") with attribute value " " (XML node with null namespace)
     1124PASS classList.replace("a", "b") with attribute value " a  \f" (XML node with null namespace)
     1125PASS classList.replace("b", "d") with attribute value "a b c" (XML node with null namespace)
     1126PASS classList.replace("c", "a") with attribute value "a b c" (XML node with null namespace)
     1127PASS classList.replace("c", "a") with attribute value "c b a" (XML node with null namespace)
     1128PASS classList.replace("a", "c") with attribute value "a b a" (XML node with null namespace)
     1129PASS classList.replace("b", "c") with attribute value "a b a" (XML node with null namespace)
     1130PASS classList.replace("a", "c") with attribute value "   a  a b" (XML node with null namespace)
     1131PASS classList.replace("b", "c") with attribute value "   a  a b" (XML node with null namespace)
     1132PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XML node with null namespace)
     1133PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XML node with null namespace)
     1134PASS classList.replace(null, "b") with attribute value "a null" (XML node with null namespace)
     1135PASS classList.replace("a", null) with attribute value "a b" (XML node with null namespace)
     1136PASS classList.replace(undefined, "b") with attribute value "a undefined" (XML node with null namespace)
     1137PASS classList.replace("a", undefined) with attribute value "a b" (XML node with null namespace)
    11381138PASS Assigning to classList (foo node)
    11391139PASS .supports() must throw TypeError (foo node)
     
    13951395PASS classList.replace("b", " a") with attribute value null (foo node)
    13961396PASS classList.replace("b", "a ") with attribute value null (foo node)
    1397 FAIL classList.replace("a", "a") with attribute value "a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1398 FAIL classList.replace("a", "b") with attribute value "a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1399 FAIL classList.replace("A", "b") with attribute value "a" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1400 FAIL classList.replace("b", "A") with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1401 FAIL classList.replace("c", "a") with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1402 FAIL classList.replace("d", "e") with attribute value "a b c" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1403 FAIL classList.replace("a", "a") with attribute value "a a a  b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1404 FAIL classList.replace("c", "d") with attribute value "a a a  b" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1405 FAIL classList.replace("a", "b") with attribute value null (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1406 FAIL classList.replace("a", "b") with attribute value "" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1407 FAIL classList.replace("a", "b") with attribute value " " (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
    1408 FAIL classList.replace("a", "b") with attribute value " a  \f" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1409 FAIL classList.replace("b", "d") with attribute value "a b c" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1410 FAIL classList.replace("c", "a") with attribute value "a b c" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1411 FAIL classList.replace("c", "a") with attribute value "c b a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1412 FAIL classList.replace("a", "c") with attribute value "a b a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1413 FAIL classList.replace("b", "c") with attribute value "a b a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1414 FAIL classList.replace("a", "c") with attribute value "   a  a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1415 FAIL classList.replace("b", "c") with attribute value "   a  a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1416 FAIL classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1417 FAIL classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1418 FAIL classList.replace(null, "b") with attribute value "a null" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1419 FAIL classList.replace("a", null) with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1420 FAIL classList.replace(undefined, "b") with attribute value "a undefined" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
    1421 FAIL classList.replace("a", undefined) with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
     1397PASS classList.replace("a", "a") with attribute value "a" (foo node)
     1398PASS classList.replace("a", "b") with attribute value "a" (foo node)
     1399PASS classList.replace("A", "b") with attribute value "a" (foo node)
     1400PASS classList.replace("b", "A") with attribute value "a b" (foo node)
     1401PASS classList.replace("c", "a") with attribute value "a b" (foo node)
     1402PASS classList.replace("d", "e") with attribute value "a b c" (foo node)
     1403PASS classList.replace("a", "a") with attribute value "a a a  b" (foo node)
     1404PASS classList.replace("c", "d") with attribute value "a a a  b" (foo node)
     1405PASS classList.replace("a", "b") with attribute value null (foo node)
     1406PASS classList.replace("a", "b") with attribute value "" (foo node)
     1407PASS classList.replace("a", "b") with attribute value " " (foo node)
     1408PASS classList.replace("a", "b") with attribute value " a  \f" (foo node)
     1409PASS classList.replace("b", "d") with attribute value "a b c" (foo node)
     1410PASS classList.replace("c", "a") with attribute value "a b c" (foo node)
     1411PASS classList.replace("c", "a") with attribute value "c b a" (foo node)
     1412PASS classList.replace("a", "c") with attribute value "a b a" (foo node)
     1413PASS classList.replace("b", "c") with attribute value "a b a" (foo node)
     1414PASS classList.replace("a", "c") with attribute value "   a  a b" (foo node)
     1415PASS classList.replace("b", "c") with attribute value "   a  a b" (foo node)
     1416PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (foo node)
     1417PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (foo node)
     1418PASS classList.replace(null, "b") with attribute value "a null" (foo node)
     1419PASS classList.replace("a", null) with attribute value "a b" (foo node)
     1420PASS classList.replace(undefined, "b") with attribute value "a undefined" (foo node)
     1421PASS classList.replace("a", undefined) with attribute value "a b" (foo node)
    14221422
  • trunk/Source/WebCore/ChangeLog

    r229564 r229566  
     12018-03-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Return boolean from DOMTokenList's replace() method
     4        https://bugs.webkit.org/show_bug.cgi?id=183567
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Have DOMTokenList's replace() method return a boolean indicating if the
     9        token was replaced, as per:
     10        - https://dom.spec.whatwg.org/#dom-domtokenlist-replace
     11
     12        This is a recent addition to the DOM specification:
     13        - https://github.com/whatwg/dom/pull/582
     14
     15        No new tests, rebaselined existing test.
     16
     17        * html/DOMTokenList.cpp:
     18        (WebCore::replaceInOrderedSet):
     19        (WebCore::DOMTokenList::replace):
     20        * html/DOMTokenList.h:
     21        * html/DOMTokenList.idl:
     22
    1232018-03-12  Brian Burg  <bburg@apple.com>
    224
  • trunk/Source/WebCore/html/DOMTokenList.cpp

    r223330 r229566  
    158158}
    159159
     160static inline void replaceInOrderedSet(Vector<AtomicString>& tokens, size_t tokenIndex, const AtomicString& newToken)
     161{
     162    ASSERT(tokenIndex != notFound);
     163    ASSERT(tokenIndex < tokens.size());
     164
     165    auto newTokenIndex = tokens.find(newToken);
     166    if (newTokenIndex == notFound) {
     167        tokens[tokenIndex] = newToken;
     168        return;
     169    }
     170
     171    if (newTokenIndex == tokenIndex)
     172        return;
     173
     174    if (newTokenIndex > tokenIndex) {
     175        tokens[tokenIndex] = newToken;
     176        tokens.remove(newTokenIndex);
     177    } else
     178        tokens.remove(tokenIndex);
     179}
     180
    160181// https://dom.spec.whatwg.org/#dom-domtokenlist-replace
    161 ExceptionOr<void> DOMTokenList::replace(const AtomicString& item, const AtomicString& replacement)
    162 {
    163     if (item.isEmpty() || replacement.isEmpty())
     182ExceptionOr<bool> DOMTokenList::replace(const AtomicString& token, const AtomicString& newToken)
     183{
     184    if (token.isEmpty() || newToken.isEmpty())
    164185        return Exception { SyntaxError };
    165186
    166     if (tokenContainsHTMLSpace(item) || tokenContainsHTMLSpace(replacement))
     187    if (tokenContainsHTMLSpace(token) || tokenContainsHTMLSpace(newToken))
    167188        return Exception { InvalidCharacterError };
    168189
    169190    auto& tokens = this->tokens();
    170191
    171     auto matchesItemOrReplacement = [&](auto& token) {
    172         return token == item || token == replacement;
    173     };
    174 
    175     size_t index = tokens.findMatching(matchesItemOrReplacement);
    176     if (index == notFound)
    177         return { };
    178 
    179     tokens[index] = replacement;
    180     tokens.removeFirstMatching(matchesItemOrReplacement, index + 1);
    181     ASSERT(item == replacement || tokens.find(item) == notFound);
    182     ASSERT(tokens.reverseFind(replacement) == index);
    183 
    184     updateAssociatedAttributeFromTokens();
    185 
    186     return { };
     192    auto tokenIndex = tokens.find(token);
     193    if (tokenIndex == notFound)
     194        return false;
     195
     196    replaceInOrderedSet(tokens, tokenIndex, newToken);
     197    ASSERT(token == newToken || tokens.find(token) == notFound);
     198
     199    updateAssociatedAttributeFromTokens();
     200
     201    return true;
    187202}
    188203
  • trunk/Source/WebCore/html/DOMTokenList.h

    r222613 r229566  
    5050    ExceptionOr<void> remove(const AtomicString&);
    5151    WEBCORE_EXPORT ExceptionOr<bool> toggle(const AtomicString&, std::optional<bool> force);
    52     ExceptionOr<void> replace(const AtomicString& token, const AtomicString& newToken);
     52    ExceptionOr<bool> replace(const AtomicString& token, const AtomicString& newToken);
    5353    ExceptionOr<bool> supports(StringView token);
    5454
  • trunk/Source/WebCore/html/DOMTokenList.idl

    r216339 r229566  
    3434    [CEReactions, MayThrowException] void remove(DOMString... tokens);
    3535    [CEReactions, MayThrowException] boolean toggle(DOMString token, optional boolean force);
    36     [CEReactions, MayThrowException] void replace(DOMString token, DOMString newToken);
     36    [CEReactions, MayThrowException] boolean replace(DOMString token, DOMString newToken);
    3737    [MayThrowException] boolean supports(DOMString token);
    3838    [CEReactions] stringifier attribute DOMString value;
Note: See TracChangeset for help on using the changeset viewer.