Title: [229566] trunk
Revision
229566
Author
cdu...@apple.com
Date
2018-03-12 18:37:23 -0700 (Mon, 12 Mar 2018)

Log 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:
- https://dom.spec.whatwg.org/#dom-domtokenlist-replace

This is a recent addition to the DOM specification:
- https://github.com/whatwg/dom/pull/582

No new tests, rebaselined existing test.

* html/DOMTokenList.cpp:
(WebCore::replaceInOrderedSet):
(WebCore::DOMTokenList::replace):
* html/DOMTokenList.h:
* html/DOMTokenList.idl:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (229565 => 229566)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-03-13 01:29:46 UTC (rev 229565)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-03-13 01:37:23 UTC (rev 229566)
@@ -1,3 +1,14 @@
+2018-03-12  Chris Dumez  <cdu...@apple.com>
+
+        Return boolean from DOMTokenList's replace() method
+        https://bugs.webkit.org/show_bug.cgi?id=183567
+
+        Reviewed by Youenn Fablet.
+
+        Rebaseline web platform test now that all checks are passing.
+
+        * web-platform-tests/dom/nodes/Element-classlist-expected.txt:
+
 2018-03-12  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rebaseline two cssom tests after r229544.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist-expected.txt (229565 => 229566)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist-expected.txt	2018-03-13 01:29:46 UTC (rev 229565)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist-expected.txt	2018-03-13 01:37:23 UTC (rev 229566)
@@ -258,31 +258,31 @@
 PASS classList.replace("b", "a\r") with attribute value null (HTML node) 
 PASS classList.replace("b", " a") with attribute value null (HTML node) 
 PASS classList.replace("b", "a ") with attribute value null (HTML node) 
-FAIL classList.replace("a", "a") with attribute value "a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "a" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("A", "b") with attribute value "a" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("b", "A") with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("c", "a") with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-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
-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
-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
-FAIL classList.replace("a", "b") with attribute value null (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "" (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " " (HTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " a  \f" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-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
-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
-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
-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
-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
-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
-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
-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
-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
-FAIL classList.replace(null, "b") with attribute value "a null" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", null) with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace(undefined, "b") with attribute value "a undefined" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", undefined) with attribute value "a b" (HTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
+PASS classList.replace("a", "a") with attribute value "a" (HTML node) 
+PASS classList.replace("a", "b") with attribute value "a" (HTML node) 
+PASS classList.replace("A", "b") with attribute value "a" (HTML node) 
+PASS classList.replace("b", "A") with attribute value "a b" (HTML node) 
+PASS classList.replace("c", "a") with attribute value "a b" (HTML node) 
+PASS classList.replace("d", "e") with attribute value "a b c" (HTML node) 
+PASS classList.replace("a", "a") with attribute value "a a a  b" (HTML node) 
+PASS classList.replace("c", "d") with attribute value "a a a  b" (HTML node) 
+PASS classList.replace("a", "b") with attribute value null (HTML node) 
+PASS classList.replace("a", "b") with attribute value "" (HTML node) 
+PASS classList.replace("a", "b") with attribute value " " (HTML node) 
+PASS classList.replace("a", "b") with attribute value " a  \f" (HTML node) 
+PASS classList.replace("b", "d") with attribute value "a b c" (HTML node) 
+PASS classList.replace("c", "a") with attribute value "a b c" (HTML node) 
+PASS classList.replace("c", "a") with attribute value "c b a" (HTML node) 
+PASS classList.replace("a", "c") with attribute value "a b a" (HTML node) 
+PASS classList.replace("b", "c") with attribute value "a b a" (HTML node) 
+PASS classList.replace("a", "c") with attribute value "   a  a b" (HTML node) 
+PASS classList.replace("b", "c") with attribute value "   a  a b" (HTML node) 
+PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (HTML node) 
+PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (HTML node) 
+PASS classList.replace(null, "b") with attribute value "a null" (HTML node) 
+PASS classList.replace("a", null) with attribute value "a b" (HTML node) 
+PASS classList.replace(undefined, "b") with attribute value "a undefined" (HTML node) 
+PASS classList.replace("a", undefined) with attribute value "a b" (HTML node) 
 PASS Assigning to classList (XHTML node) 
 PASS .supports() must throw TypeError (XHTML node) 
 PASS classList.length when removed (XHTML node) 
@@ -542,31 +542,31 @@
 PASS classList.replace("b", "a\r") with attribute value null (XHTML node) 
 PASS classList.replace("b", " a") with attribute value null (XHTML node) 
 PASS classList.replace("b", "a ") with attribute value null (XHTML node) 
-FAIL classList.replace("a", "a") with attribute value "a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "a" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("A", "b") with attribute value "a" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("b", "A") with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("c", "a") with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-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
-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
-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
-FAIL classList.replace("a", "b") with attribute value null (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "" (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " " (XHTML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " a  \f" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-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
-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
-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
-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
-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
-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
-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
-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
-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
-FAIL classList.replace(null, "b") with attribute value "a null" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", null) with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace(undefined, "b") with attribute value "a undefined" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", undefined) with attribute value "a b" (XHTML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
+PASS classList.replace("a", "a") with attribute value "a" (XHTML node) 
+PASS classList.replace("a", "b") with attribute value "a" (XHTML node) 
+PASS classList.replace("A", "b") with attribute value "a" (XHTML node) 
+PASS classList.replace("b", "A") with attribute value "a b" (XHTML node) 
+PASS classList.replace("c", "a") with attribute value "a b" (XHTML node) 
+PASS classList.replace("d", "e") with attribute value "a b c" (XHTML node) 
+PASS classList.replace("a", "a") with attribute value "a a a  b" (XHTML node) 
+PASS classList.replace("c", "d") with attribute value "a a a  b" (XHTML node) 
+PASS classList.replace("a", "b") with attribute value null (XHTML node) 
+PASS classList.replace("a", "b") with attribute value "" (XHTML node) 
+PASS classList.replace("a", "b") with attribute value " " (XHTML node) 
+PASS classList.replace("a", "b") with attribute value " a  \f" (XHTML node) 
+PASS classList.replace("b", "d") with attribute value "a b c" (XHTML node) 
+PASS classList.replace("c", "a") with attribute value "a b c" (XHTML node) 
+PASS classList.replace("c", "a") with attribute value "c b a" (XHTML node) 
+PASS classList.replace("a", "c") with attribute value "a b a" (XHTML node) 
+PASS classList.replace("b", "c") with attribute value "a b a" (XHTML node) 
+PASS classList.replace("a", "c") with attribute value "   a  a b" (XHTML node) 
+PASS classList.replace("b", "c") with attribute value "   a  a b" (XHTML node) 
+PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XHTML node) 
+PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (XHTML node) 
+PASS classList.replace(null, "b") with attribute value "a null" (XHTML node) 
+PASS classList.replace("a", null) with attribute value "a b" (XHTML node) 
+PASS classList.replace(undefined, "b") with attribute value "a undefined" (XHTML node) 
+PASS classList.replace("a", undefined) with attribute value "a b" (XHTML node) 
 PASS Assigning to classList (MathML node) 
 PASS .supports() must throw TypeError (MathML node) 
 PASS classList.length when removed (MathML node) 
@@ -826,31 +826,31 @@
 PASS classList.replace("b", "a\r") with attribute value null (MathML node) 
 PASS classList.replace("b", " a") with attribute value null (MathML node) 
 PASS classList.replace("b", "a ") with attribute value null (MathML node) 
-FAIL classList.replace("a", "a") with attribute value "a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "a" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("A", "b") with attribute value "a" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("b", "A") with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("c", "a") with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-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
-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
-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
-FAIL classList.replace("a", "b") with attribute value null (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "" (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " " (MathML node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " a  \f" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-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
-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
-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
-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
-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
-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
-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
-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
-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
-FAIL classList.replace(null, "b") with attribute value "a null" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", null) with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace(undefined, "b") with attribute value "a undefined" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", undefined) with attribute value "a b" (MathML node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
+PASS classList.replace("a", "a") with attribute value "a" (MathML node) 
+PASS classList.replace("a", "b") with attribute value "a" (MathML node) 
+PASS classList.replace("A", "b") with attribute value "a" (MathML node) 
+PASS classList.replace("b", "A") with attribute value "a b" (MathML node) 
+PASS classList.replace("c", "a") with attribute value "a b" (MathML node) 
+PASS classList.replace("d", "e") with attribute value "a b c" (MathML node) 
+PASS classList.replace("a", "a") with attribute value "a a a  b" (MathML node) 
+PASS classList.replace("c", "d") with attribute value "a a a  b" (MathML node) 
+PASS classList.replace("a", "b") with attribute value null (MathML node) 
+PASS classList.replace("a", "b") with attribute value "" (MathML node) 
+PASS classList.replace("a", "b") with attribute value " " (MathML node) 
+PASS classList.replace("a", "b") with attribute value " a  \f" (MathML node) 
+PASS classList.replace("b", "d") with attribute value "a b c" (MathML node) 
+PASS classList.replace("c", "a") with attribute value "a b c" (MathML node) 
+PASS classList.replace("c", "a") with attribute value "c b a" (MathML node) 
+PASS classList.replace("a", "c") with attribute value "a b a" (MathML node) 
+PASS classList.replace("b", "c") with attribute value "a b a" (MathML node) 
+PASS classList.replace("a", "c") with attribute value "   a  a b" (MathML node) 
+PASS classList.replace("b", "c") with attribute value "   a  a b" (MathML node) 
+PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (MathML node) 
+PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (MathML node) 
+PASS classList.replace(null, "b") with attribute value "a null" (MathML node) 
+PASS classList.replace("a", null) with attribute value "a b" (MathML node) 
+PASS classList.replace(undefined, "b") with attribute value "a undefined" (MathML node) 
+PASS classList.replace("a", undefined) with attribute value "a b" (MathML node) 
 PASS Assigning to classList (XML node with null namespace) 
 PASS .supports() must throw TypeError (XML node with null namespace) 
 PASS classList.length when removed (XML node with null namespace) 
@@ -1110,31 +1110,31 @@
 PASS classList.replace("b", "a\r") with attribute value null (XML node with null namespace) 
 PASS classList.replace("b", " a") with attribute value null (XML node with null namespace) 
 PASS classList.replace("b", "a ") with attribute value null (XML node with null namespace) 
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
-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
+PASS classList.replace("a", "a") with attribute value "a" (XML node with null namespace) 
+PASS classList.replace("a", "b") with attribute value "a" (XML node with null namespace) 
+PASS classList.replace("A", "b") with attribute value "a" (XML node with null namespace) 
+PASS classList.replace("b", "A") with attribute value "a b" (XML node with null namespace) 
+PASS classList.replace("c", "a") with attribute value "a b" (XML node with null namespace) 
+PASS classList.replace("d", "e") with attribute value "a b c" (XML node with null namespace) 
+PASS classList.replace("a", "a") with attribute value "a a a  b" (XML node with null namespace) 
+PASS classList.replace("c", "d") with attribute value "a a a  b" (XML node with null namespace) 
+PASS classList.replace("a", "b") with attribute value null (XML node with null namespace) 
+PASS classList.replace("a", "b") with attribute value "" (XML node with null namespace) 
+PASS classList.replace("a", "b") with attribute value " " (XML node with null namespace) 
+PASS classList.replace("a", "b") with attribute value " a  \f" (XML node with null namespace) 
+PASS classList.replace("b", "d") with attribute value "a b c" (XML node with null namespace) 
+PASS classList.replace("c", "a") with attribute value "a b c" (XML node with null namespace) 
+PASS classList.replace("c", "a") with attribute value "c b a" (XML node with null namespace) 
+PASS classList.replace("a", "c") with attribute value "a b a" (XML node with null namespace) 
+PASS classList.replace("b", "c") with attribute value "a b a" (XML node with null namespace) 
+PASS classList.replace("a", "c") with attribute value "   a  a b" (XML node with null namespace) 
+PASS classList.replace("b", "c") with attribute value "   a  a b" (XML node with null namespace) 
+PASS 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) 
+PASS 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) 
+PASS classList.replace(null, "b") with attribute value "a null" (XML node with null namespace) 
+PASS classList.replace("a", null) with attribute value "a b" (XML node with null namespace) 
+PASS classList.replace(undefined, "b") with attribute value "a undefined" (XML node with null namespace) 
+PASS classList.replace("a", undefined) with attribute value "a b" (XML node with null namespace) 
 PASS Assigning to classList (foo node) 
 PASS .supports() must throw TypeError (foo node) 
 PASS classList.length when removed (foo node) 
@@ -1394,29 +1394,29 @@
 PASS classList.replace("b", "a\r") with attribute value null (foo node) 
 PASS classList.replace("b", " a") with attribute value null (foo node) 
 PASS classList.replace("b", "a ") with attribute value null (foo node) 
-FAIL classList.replace("a", "a") with attribute value "a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "a" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("A", "b") with attribute value "a" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("b", "A") with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("c", "a") with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-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
-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
-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
-FAIL classList.replace("a", "b") with attribute value null (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value "" (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " " (foo node) assert_equals: wrong return value expected (boolean) false but got (undefined) undefined
-FAIL classList.replace("a", "b") with attribute value " a  \f" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-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
-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
-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
-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
-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
-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
-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
-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
-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
-FAIL classList.replace(null, "b") with attribute value "a null" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", null) with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace(undefined, "b") with attribute value "a undefined" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
-FAIL classList.replace("a", undefined) with attribute value "a b" (foo node) assert_equals: wrong return value expected (boolean) true but got (undefined) undefined
+PASS classList.replace("a", "a") with attribute value "a" (foo node) 
+PASS classList.replace("a", "b") with attribute value "a" (foo node) 
+PASS classList.replace("A", "b") with attribute value "a" (foo node) 
+PASS classList.replace("b", "A") with attribute value "a b" (foo node) 
+PASS classList.replace("c", "a") with attribute value "a b" (foo node) 
+PASS classList.replace("d", "e") with attribute value "a b c" (foo node) 
+PASS classList.replace("a", "a") with attribute value "a a a  b" (foo node) 
+PASS classList.replace("c", "d") with attribute value "a a a  b" (foo node) 
+PASS classList.replace("a", "b") with attribute value null (foo node) 
+PASS classList.replace("a", "b") with attribute value "" (foo node) 
+PASS classList.replace("a", "b") with attribute value " " (foo node) 
+PASS classList.replace("a", "b") with attribute value " a  \f" (foo node) 
+PASS classList.replace("b", "d") with attribute value "a b c" (foo node) 
+PASS classList.replace("c", "a") with attribute value "a b c" (foo node) 
+PASS classList.replace("c", "a") with attribute value "c b a" (foo node) 
+PASS classList.replace("a", "c") with attribute value "a b a" (foo node) 
+PASS classList.replace("b", "c") with attribute value "a b a" (foo node) 
+PASS classList.replace("a", "c") with attribute value "   a  a b" (foo node) 
+PASS classList.replace("b", "c") with attribute value "   a  a b" (foo node) 
+PASS classList.replace("a", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (foo node) 
+PASS classList.replace("b", "c") with attribute value "\t\n\f\r a\t\n\f\r b\t\n\f\r " (foo node) 
+PASS classList.replace(null, "b") with attribute value "a null" (foo node) 
+PASS classList.replace("a", null) with attribute value "a b" (foo node) 
+PASS classList.replace(undefined, "b") with attribute value "a undefined" (foo node) 
+PASS classList.replace("a", undefined) with attribute value "a b" (foo node) 
 

Modified: trunk/Source/WebCore/ChangeLog (229565 => 229566)


--- trunk/Source/WebCore/ChangeLog	2018-03-13 01:29:46 UTC (rev 229565)
+++ trunk/Source/WebCore/ChangeLog	2018-03-13 01:37:23 UTC (rev 229566)
@@ -1,3 +1,25 @@
+2018-03-12  Chris Dumez  <cdu...@apple.com>
+
+        Return boolean from DOMTokenList's replace() method
+        https://bugs.webkit.org/show_bug.cgi?id=183567
+
+        Reviewed by Youenn Fablet.
+
+        Have DOMTokenList's replace() method return a boolean indicating if the
+        token was replaced, as per:
+        - https://dom.spec.whatwg.org/#dom-domtokenlist-replace
+
+        This is a recent addition to the DOM specification:
+        - https://github.com/whatwg/dom/pull/582
+
+        No new tests, rebaselined existing test.
+
+        * html/DOMTokenList.cpp:
+        (WebCore::replaceInOrderedSet):
+        (WebCore::DOMTokenList::replace):
+        * html/DOMTokenList.h:
+        * html/DOMTokenList.idl:
+
 2018-03-12  Brian Burg  <bb...@apple.com>
 
         Ignore some deprecation warnings encountered when compiling with newer versions of ICU

Modified: trunk/Source/WebCore/html/DOMTokenList.cpp (229565 => 229566)


--- trunk/Source/WebCore/html/DOMTokenList.cpp	2018-03-13 01:29:46 UTC (rev 229565)
+++ trunk/Source/WebCore/html/DOMTokenList.cpp	2018-03-13 01:37:23 UTC (rev 229566)
@@ -157,33 +157,48 @@
     return true;
 }
 
+static inline void replaceInOrderedSet(Vector<AtomicString>& tokens, size_t tokenIndex, const AtomicString& newToken)
+{
+    ASSERT(tokenIndex != notFound);
+    ASSERT(tokenIndex < tokens.size());
+
+    auto newTokenIndex = tokens.find(newToken);
+    if (newTokenIndex == notFound) {
+        tokens[tokenIndex] = newToken;
+        return;
+    }
+
+    if (newTokenIndex == tokenIndex)
+        return;
+
+    if (newTokenIndex > tokenIndex) {
+        tokens[tokenIndex] = newToken;
+        tokens.remove(newTokenIndex);
+    } else
+        tokens.remove(tokenIndex);
+}
+
 // https://dom.spec.whatwg.org/#dom-domtokenlist-replace
-ExceptionOr<void> DOMTokenList::replace(const AtomicString& item, const AtomicString& replacement)
+ExceptionOr<bool> DOMTokenList::replace(const AtomicString& token, const AtomicString& newToken)
 {
-    if (item.isEmpty() || replacement.isEmpty())
+    if (token.isEmpty() || newToken.isEmpty())
         return Exception { SyntaxError };
 
-    if (tokenContainsHTMLSpace(item) || tokenContainsHTMLSpace(replacement))
+    if (tokenContainsHTMLSpace(token) || tokenContainsHTMLSpace(newToken))
         return Exception { InvalidCharacterError };
 
     auto& tokens = this->tokens();
 
-    auto matchesItemOrReplacement = [&](auto& token) {
-        return token == item || token == replacement;
-    };
+    auto tokenIndex = tokens.find(token);
+    if (tokenIndex == notFound)
+        return false;
 
-    size_t index = tokens.findMatching(matchesItemOrReplacement);
-    if (index == notFound)
-        return { };
+    replaceInOrderedSet(tokens, tokenIndex, newToken);
+    ASSERT(token == newToken || tokens.find(token) == notFound);
 
-    tokens[index] = replacement;
-    tokens.removeFirstMatching(matchesItemOrReplacement, index + 1);
-    ASSERT(item == replacement || tokens.find(item) == notFound);
-    ASSERT(tokens.reverseFind(replacement) == index);
-
     updateAssociatedAttributeFromTokens();
 
-    return { };
+    return true;
 }
 
 // https://dom.spec.whatwg.org/#concept-domtokenlist-validation

Modified: trunk/Source/WebCore/html/DOMTokenList.h (229565 => 229566)


--- trunk/Source/WebCore/html/DOMTokenList.h	2018-03-13 01:29:46 UTC (rev 229565)
+++ trunk/Source/WebCore/html/DOMTokenList.h	2018-03-13 01:37:23 UTC (rev 229566)
@@ -49,7 +49,7 @@
     ExceptionOr<void> remove(const Vector<String>&);
     ExceptionOr<void> remove(const AtomicString&);
     WEBCORE_EXPORT ExceptionOr<bool> toggle(const AtomicString&, std::optional<bool> force);
-    ExceptionOr<void> replace(const AtomicString& token, const AtomicString& newToken);
+    ExceptionOr<bool> replace(const AtomicString& token, const AtomicString& newToken);
     ExceptionOr<bool> supports(StringView token);
 
     Element& element() const { return m_element; }

Modified: trunk/Source/WebCore/html/DOMTokenList.idl (229565 => 229566)


--- trunk/Source/WebCore/html/DOMTokenList.idl	2018-03-13 01:29:46 UTC (rev 229565)
+++ trunk/Source/WebCore/html/DOMTokenList.idl	2018-03-13 01:37:23 UTC (rev 229566)
@@ -33,7 +33,7 @@
     [CEReactions, MayThrowException] void add(DOMString... tokens);
     [CEReactions, MayThrowException] void remove(DOMString... tokens);
     [CEReactions, MayThrowException] boolean toggle(DOMString token, optional boolean force);
-    [CEReactions, MayThrowException] void replace(DOMString token, DOMString newToken);
+    [CEReactions, MayThrowException] boolean replace(DOMString token, DOMString newToken);
     [MayThrowException] boolean supports(DOMString token);
     [CEReactions] stringifier attribute DOMString value;
     iterable<DOMString>;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to