Title: [199296] trunk
Revision
199296
Author
[email protected]
Date
2016-04-11 09:50:44 -0700 (Mon, 11 Apr 2016)

Log Message

DOMTokenList.contains() should not throw
https://bugs.webkit.org/show_bug.cgi?id=156453

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Re-sync dom/nodes/Element-classlist.html with upstream @26308720.

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

Source/WebCore:

DOMTokenList.contains() should not throw if the input token is invalid:
https://github.com/whatwg/dom/commit/6d3076e3cbcba662489b272a718bc6b8c0082a74

We now return false in such cases, instead of throwing, which should be
safe with regards to backward compatibility.

No new tests, already covered by existing tests.

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

LayoutTests:

Update existing layout tests now that DOMTokenList.contains() no longer
throws when called with an invalid token.

* fast/dom/HTMLElement/class-list-expected.txt:
* fast/dom/HTMLElement/class-list-quirks-expected.txt:
* fast/dom/HTMLElement/script-tests/class-list.js:
(shouldThrowDOMException): Deleted.
* fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt:
* fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js:
(shouldThrowDOMException): Deleted.
* fast/dom/rel-list-expected.txt:
* fast/dom/rel-list.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (199295 => 199296)


--- trunk/LayoutTests/ChangeLog	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/ChangeLog	2016-04-11 16:50:44 UTC (rev 199296)
@@ -1,3 +1,23 @@
+2016-04-11  Chris Dumez  <[email protected]>
+
+        DOMTokenList.contains() should not throw
+        https://bugs.webkit.org/show_bug.cgi?id=156453
+
+        Reviewed by Ryosuke Niwa.
+
+        Update existing layout tests now that DOMTokenList.contains() no longer
+        throws when called with an invalid token.
+
+        * fast/dom/HTMLElement/class-list-expected.txt:
+        * fast/dom/HTMLElement/class-list-quirks-expected.txt:
+        * fast/dom/HTMLElement/script-tests/class-list.js:
+        (shouldThrowDOMException): Deleted.
+        * fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt:
+        * fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js:
+        (shouldThrowDOMException): Deleted.
+        * fast/dom/rel-list-expected.txt:
+        * fast/dom/rel-list.html:
+
 2016-04-11  Frederic Wang  <[email protected]>
 
         Refactor RenderMathMLFraction layout to avoid using flexbox

Modified: trunk/LayoutTests/fast/dom/HTMLElement/class-list-expected.txt (199295 => 199296)


--- trunk/LayoutTests/fast/dom/HTMLElement/class-list-expected.txt	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/HTMLElement/class-list-expected.txt	2016-04-11 16:50:44 UTC (rev 199296)
@@ -40,8 +40,8 @@
 PASS element.className is "x y"
 PASS element.className is "y"
 Test invalid tokens
-PASS element.classList.contains('') threw expected DOMException with code 12
-PASS element.classList.contains('x y') threw expected DOMException with code 5
+PASS element.classList.contains('') is false
+PASS element.classList.contains('x y') is false
 PASS element.classList.add('') threw expected DOMException with code 12
 PASS element.classList.add('x y') threw expected DOMException with code 5
 PASS element.classList.remove('') threw expected DOMException with code 12

Modified: trunk/LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt (199295 => 199296)


--- trunk/LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/HTMLElement/class-list-quirks-expected.txt	2016-04-11 16:50:44 UTC (rev 199296)
@@ -40,8 +40,8 @@
 PASS element.className is "x y"
 PASS element.className is "y"
 Test invalid tokens
-PASS element.classList.contains('') threw expected DOMException with code 12
-PASS element.classList.contains('x y') threw expected DOMException with code 5
+PASS element.classList.contains('') is false
+PASS element.classList.contains('x y') is false
 PASS element.classList.add('') threw expected DOMException with code 12
 PASS element.classList.add('x y') threw expected DOMException with code 5
 PASS element.classList.remove('') threw expected DOMException with code 12

Modified: trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js (199295 => 199296)


--- trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js	2016-04-11 16:50:44 UTC (rev 199296)
@@ -149,14 +149,10 @@
 }
 
 createElement('x');
-shouldThrowDOMException(function() {
-    element.classList.contains('');
-}, DOMException.SYNTAX_ERR);
+shouldBeFalse("element.classList.contains('')");
 
 createElement('x y');
-shouldThrowDOMException(function() {
-    element.classList.contains('x y');
-}, DOMException.INVALID_CHARACTER_ERR);
+shouldBeFalse("element.classList.contains('x y')");
 
 createElement('');
 shouldThrowDOMException(function() {

Modified: trunk/LayoutTests/fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt (199295 => 199296)


--- trunk/LayoutTests/fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/HTMLOutputElement/dom-settable-token-list-expected.txt	2016-04-11 16:50:44 UTC (rev 199296)
@@ -32,8 +32,8 @@
 PASS element.htmlFor.toString() is "x y"
 PASS element.htmlFor.toString() is "y"
 - Test invalid tokens
-PASS element.htmlFor.contains('') threw expected DOMException with code 12
-PASS element.htmlFor.contains('x y') threw expected DOMException with code 5
+PASS element.htmlFor.contains('') is false
+PASS element.htmlFor.contains('x y') is false
 PASS element.htmlFor.add('') threw expected DOMException with code 12
 PASS element.htmlFor.add('x y') threw expected DOMException with code 5
 PASS element.htmlFor.remove('') threw expected DOMException with code 12

Modified: trunk/LayoutTests/fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js (199295 => 199296)


--- trunk/LayoutTests/fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/HTMLOutputElement/script-tests/dom-settable-token-list.js	2016-04-11 16:50:44 UTC (rev 199296)
@@ -139,14 +139,10 @@
 }
 
 createElement('x');
-shouldThrowDOMException(function() {
-    element.htmlFor.contains('');
-}, DOMException.SYNTAX_ERR);
+shouldBeFalse("element.htmlFor.contains('')");
 
 createElement('x y');
-shouldThrowDOMException(function() {
-    element.htmlFor.contains('x y');
-}, DOMException.INVALID_CHARACTER_ERR);
+shouldBeFalse("element.htmlFor.contains('x y')");
 
 createElement('');
 shouldThrowDOMException(function() {

Modified: trunk/LayoutTests/fast/dom/rel-list-expected.txt (199295 => 199296)


--- trunk/LayoutTests/fast/dom/rel-list-expected.txt	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/rel-list-expected.txt	2016-04-11 16:50:44 UTC (rev 199296)
@@ -61,8 +61,8 @@
 PASS element.rel is "x y"
 PASS element.rel is "y"
 Test invalid tokens
-PASS element.relList.contains("") threw exception Error: SyntaxError: DOM Exception 12.
-PASS element.relList.contains("x y") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS element.relList.contains("") is false
+PASS element.relList.contains("x y") is false
 PASS element.relList.add("") threw exception Error: SyntaxError: DOM Exception 12.
 PASS element.relList.add("x y") threw exception Error: InvalidCharacterError: DOM Exception 5.
 PASS element.relList.remove("") threw exception Error: SyntaxError: DOM Exception 12.
@@ -184,8 +184,8 @@
 PASS element.rel is "x y"
 PASS element.rel is "y"
 Test invalid tokens
-PASS element.relList.contains("") threw exception Error: SyntaxError: DOM Exception 12.
-PASS element.relList.contains("x y") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS element.relList.contains("") is false
+PASS element.relList.contains("x y") is false
 PASS element.relList.add("") threw exception Error: SyntaxError: DOM Exception 12.
 PASS element.relList.add("x y") threw exception Error: InvalidCharacterError: DOM Exception 5.
 PASS element.relList.remove("") threw exception Error: SyntaxError: DOM Exception 12.
@@ -307,8 +307,8 @@
 PASS element.rel is "x y"
 PASS element.rel is "y"
 Test invalid tokens
-PASS element.relList.contains("") threw exception Error: SyntaxError: DOM Exception 12.
-PASS element.relList.contains("x y") threw exception Error: InvalidCharacterError: DOM Exception 5.
+PASS element.relList.contains("") is false
+PASS element.relList.contains("x y") is false
 PASS element.relList.add("") threw exception Error: SyntaxError: DOM Exception 12.
 PASS element.relList.add("x y") threw exception Error: InvalidCharacterError: DOM Exception 5.
 PASS element.relList.remove("") threw exception Error: SyntaxError: DOM Exception 12.

Modified: trunk/LayoutTests/fast/dom/rel-list.html (199295 => 199296)


--- trunk/LayoutTests/fast/dom/rel-list.html	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/fast/dom/rel-list.html	2016-04-11 16:50:44 UTC (rev 199296)
@@ -143,10 +143,10 @@
     debug('Test invalid tokens');
 
     createElement('x');
-    shouldThrow('element.relList.contains("")');
+    shouldBeFalse('element.relList.contains("")');
 
     createElement('x y');
-    shouldThrow('element.relList.contains("x y")');
+    shouldBeFalse('element.relList.contains("x y")');
 
     createElement('');
     shouldThrow('element.relList.add("")');

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (199295 => 199296)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-04-11 16:50:44 UTC (rev 199296)
@@ -1,3 +1,15 @@
+2016-04-11  Chris Dumez  <[email protected]>
+
+        DOMTokenList.contains() should not throw
+        https://bugs.webkit.org/show_bug.cgi?id=156453
+
+        Reviewed by Ryosuke Niwa.
+
+        Re-sync dom/nodes/Element-classlist.html with upstream @26308720.
+
+        * web-platform-tests/dom/nodes/Element-classlist-expected.txt:
+        * web-platform-tests/dom/nodes/Element-classlist.html:
+
 2016-04-08  Youenn Fablet  <[email protected]>
 
         Testharness-based tests that time out should be able to produce detailed output

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist-expected.txt	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist-expected.txt	2016-04-11 16:50:44 UTC (rev 199296)
@@ -14,14 +14,17 @@
 PASS classList[index] must be undefined for negative index 
 PASS className should contain initial markup whitespace 
 FAIL classList should contain initial markup whitespace assert_equals: implicit expected " " but got ""
-PASS .contains(empty_string) must throw a SYNTAX_ERR 
+PASS .contains(empty_string) must return false 
 PASS .add(empty_string) must throw a SYNTAX_ERR 
 PASS .remove(empty_string) must throw a SYNTAX_ERR 
 PASS .toggle(empty_string) must throw a SYNTAX_ERR 
-PASS .contains(string_with_spaces) must throw an INVALID_CHARACTER_ERR 
+FAIL .replace with empty_string must throw a SYNTAX_ERR assert_throws: function "function () { elem.classList.replace('', 'foo'); }" threw object "TypeError: elem.classList.replace is not a function. (In ..." that is not a DOMException SYNTAX_ERR: property "code" is equal to undefined, expected 12
+PASS .contains(string_with_spaces) must return false 
 PASS .add(string_with_spaces) must throw an INVALID_CHARACTER_ERR 
 PASS .remove(string_with_spaces) must throw an INVALID_CHARACTER_ERR 
 PASS .toggle(string_with_spaces) must throw an INVALID_CHARACTER_ERR 
+FAIL .replace with string_with_spaces must throw a INVALID_CHARACTER_ERR assert_throws: function "function () { elem.classList.replace('z', 'a b'); }" threw object "TypeError: elem.classList.replace is not a function. (In ..." that is not a DOMException INVALID_CHARACTER_ERR: property "code" is equal to undefined, expected 5
+FAIL .replace with an already existing token foo.classList.replace is not a function. (In 'foo.classList.replace('token1', 'token3')', 'foo.classList.replace' is undefined)
 PASS computed style must update when setting .className 
 PASS classList.contains must update when .className is changed 
 PASS classList.contains must be case sensitive 
@@ -51,11 +54,20 @@
 PASS classList.toggle must not break case-sensitive CSS selector matching 
 PASS classList.toggle must be able to remove tokens 
 PASS classList.toggle must be case-sensitive when removing tokens 
+FAIL classList.replace replaces arguments passed, if they are present. secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('bar', 'baz')', 'secondelem.classList.replace' is undefined)
+FAIL classList.replace must replace existing tokens secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('foo', 'bar')', 'secondelem.classList.replace' is undefined)
+FAIL classList.replace must not break case-sensitive CSS selector matching assert_not_equals: got disallowed value "italic"
+FAIL classList.replace must replace duplicated tokens secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('token1', 'token3')', 'secondelem.classList.replace' is undefined)
+FAIL classList.replace must collapse whitespace around replaced tokens secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('token2', 'token4')', 'secondelem.classList.replace' is undefined)
+FAIL classList.replace must collapse whitespaces around each token secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('token2', 'token3')', 'secondelem.classList.replace' is undefined)
+FAIL classList.replace must collapse whitespaces around each token and remove duplicates secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('token2', 'token3')', 'secondelem.classList.replace' is undefined)
+FAIL classList.replace must collapse whitespace when replacing duplicate tokens secondelem.classList.replace is not a function. (In 'secondelem.classList.replace('token1', 'token3')', 'secondelem.classList.replace' is undefined)
 PASS CSS class selectors must stop matching when all classes have been removed 
 PASS className must be empty when all classes have been removed 
 PASS classList must stringify to an empty string when all classes have been removed 
 PASS classList.item(0) must return null when all classes have been removed 
 PASS classList[0] must be undefined when all classes have been removed 
+PASS Invoking add or remove should set the class attribute 
 PASS classList.add should treat " " as a space 
 PASS classList.add should treat \t as a space 
 PASS classList.add should treat \r as a space 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist.html (199295 => 199296)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist.html	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Element-classlist.html	2016-04-11 16:50:44 UTC (rev 199296)
@@ -66,8 +66,8 @@
   assert_equals( elem.classList.toString(), ' ', 'explicit' );
 }, 'classList should contain initial markup whitespace');
 test(function () {
-  assert_throws( 'SYNTAX_ERR', function () { elem.classList.contains(''); } );
-}, '.contains(empty_string) must throw a SYNTAX_ERR');
+  assert_false( elem.classList.contains('') );
+}, '.contains(empty_string) must return false');
 test(function () {
   assert_throws( 'SYNTAX_ERR', function () { elem.classList.add(''); } );
 }, '.add(empty_string) must throw a SYNTAX_ERR');
@@ -78,9 +78,16 @@
   assert_throws( 'SYNTAX_ERR', function () { elem.classList.toggle(''); } );
 }, '.toggle(empty_string) must throw a SYNTAX_ERR');
 test(function () {
-  assert_throws( 'INVALID_CHARACTER_ERR', function () { elem.classList.contains('a b'); } );
-}, '.contains(string_with_spaces) must throw an INVALID_CHARACTER_ERR');
+  assert_throws( 'SYNTAX_ERR', function () { elem.classList.replace('', 'foo'); } );
+  assert_throws( 'SYNTAX_ERR', function () { elem.classList.replace('foo', ''); } );
+  assert_throws( 'SYNTAX_ERR', function () { elem.classList.replace('', 'foo bar'); } );
+  assert_throws( 'SYNTAX_ERR', function () { elem.classList.replace('foo bar', ''); } );
+  assert_throws( 'SYNTAX_ERR', function () { elem.classList.replace('', ''); } );
+}, '.replace with empty_string must throw a SYNTAX_ERR');
 test(function () {
+  assert_false( elem.classList.contains('a b') );
+}, '.contains(string_with_spaces) must return false');
+test(function () {
   assert_throws( 'INVALID_CHARACTER_ERR', function () { elem.classList.add('a b'); } );
 }, '.add(string_with_spaces) must throw an INVALID_CHARACTER_ERR');
 test(function () {
@@ -89,6 +96,20 @@
 test(function () {
   assert_throws( 'INVALID_CHARACTER_ERR', function () { elem.classList.toggle('a b'); } );
 }, '.toggle(string_with_spaces) must throw an INVALID_CHARACTER_ERR');
+test(function () {
+  assert_throws( 'INVALID_CHARACTER_ERR', function () { elem.classList.replace('z', 'a b'); } );
+  assert_throws( 'INVALID_CHARACTER_ERR', function () { elem.classList.replace('a b', 'z'); } );
+  assert_throws( 'INVALID_CHARACTER_ERR', function () { elem.classList.replace('a b', 'b c'); } );
+}, '.replace with string_with_spaces must throw a INVALID_CHARACTER_ERR');
+test(function () {
+  var foo = document.createElement('div');
+  foo.className = 'token1 token2 token3'
+  foo.classList.replace('token1', 'token3');
+  assert_equals( foo.classList.length, 2 );
+  assert_false( foo.classList.contains('token1') );
+  assert_true( foo.classList.contains('token2') );
+  assert_true( foo.classList.contains('token3') );
+}, '.replace with an already existing token')
 elem.className = 'foo';
 test(function () {
   assert_equals( getComputedStyle(elem,null).fontStyle, 'italic', 'critical test; required by the testsuite' );
@@ -225,6 +246,58 @@
   assert_false( elem.classList.contains('FOO') );
 }, 'classList.toggle must be case-sensitive when removing tokens');
 test(function () {
+  secondelem.className = 'foo FOO'
+  secondelem.classList.replace('bar', 'baz');
+  assert_equals( secondelem.classList.length, 2 );
+  assert_equals( secondelem.classList + '', 'foo FOO', 'implicit' );
+  assert_equals( secondelem.classList.toString(), 'foo FOO', 'explicit' );
+}, 'classList.replace replaces arguments passed, if they are present.');
+test(function () {
+  secondelem.classList.replace('foo', 'bar');
+  assert_equals( secondelem.classList.length, 2 );
+  assert_equals( secondelem.classList + '', 'bar FOO', 'implicit' );
+  assert_equals( secondelem.classList.toString(), 'bar FOO', 'explicit' );
+  assert_false( secondelem.classList.contains('foo') );
+  assert_true( secondelem.classList.contains('bar') );
+  assert_true( secondelem.classList.contains('FOO') );
+}, 'classList.replace must replace existing tokens');
+test(function () {
+  assert_not_equals( getComputedStyle(secondelem,null).fontStyle, 'italic' );
+}, 'classList.replace must not break case-sensitive CSS selector matching');
+test(function () {
+  secondelem.className = 'token1 token2 token1'
+  secondelem.classList.replace('token1', 'token3');
+  assert_equals( secondelem.classList.length, 2 );
+  assert_false( secondelem.classList.contains('token1') );
+  assert_true( secondelem.classList.contains('token2') );
+  assert_true( secondelem.classList.contains('token3') );
+}, 'classList.replace must replace duplicated tokens');
+test(function () {
+  secondelem.className = 'token1  token2  token3';
+  secondelem.classList.replace('token2', 'token4');
+  assert_equals( secondelem.classList + '', 'token1 token4 token3', 'implicit' );
+  assert_equals( secondelem.classList.toString(), 'token1 token4 token3', 'explicit' );
+}, 'classList.replace must collapse whitespace around replaced tokens');
+test(function () {
+  secondelem.className = ' token1 token2  ';
+  secondelem.classList.replace('token2', 'token3');
+  assert_equals( secondelem.classList.length, 2 );
+  assert_equals( secondelem.classList + '', 'token1 token3', 'implicit' );
+  assert_equals( secondelem.classList.toString(), 'token1 token3', 'explicit' );
+}, 'classList.replace must collapse whitespaces around each token');
+test(function () {
+  secondelem.className = '  token1  token2  token1  ';
+  secondelem.classList.replace('token2', 'token3');
+  assert_equals( secondelem.classList + '', 'token1 token3', 'implicit' );
+  assert_equals( secondelem.classList.toString(), 'token1 token3', 'explicit' );
+}, 'classList.replace must collapse whitespaces around each token and remove duplicates');
+test(function () {
+  secondelem.className = '  token1  token2  token1  ';
+  secondelem.classList.replace('token1', 'token3');
+  assert_equals( secondelem.classList + '', 'token3 token2', 'implicit' );
+  assert_equals( secondelem.classList.toString(), 'token3 token2', 'explicit' );
+}, 'classList.replace must collapse whitespace when replacing duplicate tokens');
+test(function () {
   assert_not_equals( getComputedStyle(elem,null).fontStyle, 'italic' );
 }, 'CSS class selectors must stop matching when all classes have been removed');
 test(function () {
@@ -245,6 +318,13 @@
   WebIDL creates actual OwnProperties and then [] just acts as a normal property lookup */
   assert_equals( elem.classList[0], undefined );
 }, 'classList[0] must be undefined when all classes have been removed');
+test(function () {
+  var foo = document.createElement('div');
+  foo.classList.add();
+  assert_true( foo.hasAttribute('class') );
+  assert_equals( foo.classList + '', '', 'implicit' );
+  assert_equals( foo.classList.toString(), '', 'explicit' );
+}, 'Invoking add or remove should set the class attribute');
 // The ordered set parser must skip ASCII whitespace (U+0009, U+000A, U+000C, U+000D, and U+0020.)
 test(function () {
   var foo = document.createElement('div');

Modified: trunk/Source/WebCore/ChangeLog (199295 => 199296)


--- trunk/Source/WebCore/ChangeLog	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/Source/WebCore/ChangeLog	2016-04-11 16:50:44 UTC (rev 199296)
@@ -1,3 +1,23 @@
+2016-04-11  Chris Dumez  <[email protected]>
+
+        DOMTokenList.contains() should not throw
+        https://bugs.webkit.org/show_bug.cgi?id=156453
+
+        Reviewed by Ryosuke Niwa.
+
+        DOMTokenList.contains() should not throw if the input token is invalid:
+        https://github.com/whatwg/dom/commit/6d3076e3cbcba662489b272a718bc6b8c0082a74
+
+        We now return false in such cases, instead of throwing, which should be
+        safe with regards to backward compatibility.
+
+        No new tests, already covered by existing tests.
+
+        * html/DOMTokenList.cpp:
+        (WebCore::DOMTokenList::contains):
+        * html/DOMTokenList.h:
+        * html/DOMTokenList.idl:
+
 2016-04-11  Frederic Wang  <[email protected]>
 
         Refactor RenderMathMLFraction layout to avoid using flexbox

Modified: trunk/Source/WebCore/html/DOMTokenList.cpp (199295 => 199296)


--- trunk/Source/WebCore/html/DOMTokenList.cpp	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/Source/WebCore/html/DOMTokenList.cpp	2016-04-11 16:50:44 UTC (rev 199296)
@@ -62,11 +62,8 @@
     return true;
 }
 
-bool DOMTokenList::contains(const AtomicString& token, ExceptionCode& ec) const
+bool DOMTokenList::contains(const AtomicString& token) const
 {
-    if (!validateToken(token, ec))
-        return false;
-
     return m_tokens.contains(token);
 }
 

Modified: trunk/Source/WebCore/html/DOMTokenList.h (199295 => 199296)


--- trunk/Source/WebCore/html/DOMTokenList.h	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/Source/WebCore/html/DOMTokenList.h	2016-04-11 16:50:44 UTC (rev 199296)
@@ -47,7 +47,7 @@
     unsigned length() const;
     const AtomicString& item(unsigned index) const;
 
-    bool contains(const AtomicString&, ExceptionCode&) const;
+    bool contains(const AtomicString&) const;
     void add(const Vector<String>&, ExceptionCode&);
     void add(const AtomicString&, ExceptionCode&);
     void remove(const Vector<String>&, ExceptionCode&);

Modified: trunk/Source/WebCore/html/DOMTokenList.idl (199295 => 199296)


--- trunk/Source/WebCore/html/DOMTokenList.idl	2016-04-11 15:38:46 UTC (rev 199295)
+++ trunk/Source/WebCore/html/DOMTokenList.idl	2016-04-11 16:50:44 UTC (rev 199296)
@@ -29,7 +29,7 @@
 ] interface DOMTokenList {
     readonly attribute unsigned long length;
     getter DOMString? item(unsigned long index);
-    [RaisesException] boolean contains(DOMString token);
+    boolean contains(DOMString token);
     [RaisesException] void add(DOMString... tokens);
     [RaisesException] void remove(DOMString... tokens);
     [RaisesException, Custom] boolean toggle(DOMString token, optional boolean force);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to