Title: [174334] trunk
Revision
174334
Author
[email protected]
Date
2014-10-05 17:41:09 -0700 (Sun, 05 Oct 2014)

Log Message

Element.matches()'s argument is not supposed to be optional
https://bugs.webkit.org/show_bug.cgi?id=137427

Reviewed by Christophe Dumez.

Source/WebCore:

The argument was marked as optional, it is not supposed to:
https://dom.spec.whatwg.org/#interface-element

Also update the webkit-prefixed version: webkitMatchesSelector().

Tests: fast/dom/SelectorAPI/closest-definition.html
       fast/dom/SelectorAPI/closest-null-undefined.html
       fast/dom/SelectorAPI/matches-definition.html
       fast/dom/SelectorAPI/matches-null-undefined.html

* dom/Element.idl:

LayoutTests:

* fast/dom/SelectorAPI/matches-definition.html: Added.
* fast/dom/SelectorAPI/matches-null-undefined.html: Added.
Test for the bug.

* fast/dom/SelectorAPI/closest-definition.html: Added.
* fast/dom/SelectorAPI/closest-null-undefined.html: Added.
Similar tests for Element.closest() since those are similar APIs.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174333 => 174334)


--- trunk/LayoutTests/ChangeLog	2014-10-06 00:31:05 UTC (rev 174333)
+++ trunk/LayoutTests/ChangeLog	2014-10-06 00:41:09 UTC (rev 174334)
@@ -1,3 +1,18 @@
+2014-10-05  Benjamin Poulain  <[email protected]>
+
+        Element.matches()'s argument is not supposed to be optional
+        https://bugs.webkit.org/show_bug.cgi?id=137427
+
+        Reviewed by Christophe Dumez.
+
+        * fast/dom/SelectorAPI/matches-definition.html: Added.
+        * fast/dom/SelectorAPI/matches-null-undefined.html: Added.
+        Test for the bug.
+
+        * fast/dom/SelectorAPI/closest-definition.html: Added.
+        * fast/dom/SelectorAPI/closest-null-undefined.html: Added.
+        Similar tests for Element.closest() since those are similar APIs.
+
 2014-10-05  Chris Fleizach  <[email protected]>
 
         AX: iOS8: Crash at -[WebAccessibilityObjectWrapper accessibilityElementAtIndex:]

Added: trunk/LayoutTests/fast/dom/SelectorAPI/closest-definition-expected.txt (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/closest-definition-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/closest-definition-expected.txt	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,13 @@
+Test the definition of Element.closest().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Element.closest is undefined.
+PASS Object.getOwnPropertyDescriptor(Element.prototype, "closest").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Element.prototype, "closest").writable is true
+PASS Element.prototype.closest.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/SelectorAPI/closest-definition.html (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/closest-definition.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/closest-definition.html	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+</body>
+<script>
+description('Test the definition of Element.closest().');
+
+shouldBeUndefined('Element.closest');
+shouldBeTrue('Object.getOwnPropertyDescriptor(Element.prototype, "closest").enumerable');
+shouldBeTrue('Object.getOwnPropertyDescriptor(Element.prototype, "closest").writable');
+shouldBe('Element.prototype.closest.length', '1');
+
+</script>
+<script src=""
+</html>

Added: trunk/LayoutTests/fast/dom/SelectorAPI/closest-null-undefined-expected.txt (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/closest-null-undefined-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/closest-null-undefined-expected.txt	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,21 @@
+Test Element.closest() with no argument, null, and undefined.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementById("target1").closest() threw exception TypeError: Not enough arguments.
+PASS document.getElementById("target1").closest(null).id is "null1"
+PASS document.getElementById("target1").closest(undefined).id is "undefined1"
+PASS document.getElementById("target2").closest() threw exception TypeError: Not enough arguments.
+PASS document.getElementById("target2").closest(null).id is "null2"
+PASS document.getElementById("target2").closest(undefined) is null
+PASS document.getElementById("target3").closest() threw exception TypeError: Not enough arguments.
+PASS document.getElementById("target3").closest(null) is null
+PASS document.getElementById("target3").closest(undefined).id is "undefined3"
+PASS document.getElementById("target4").closest() threw exception TypeError: Not enough arguments.
+PASS document.getElementById("target4").closest(null) is null
+PASS document.getElementById("target4").closest(undefined) is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/SelectorAPI/closest-null-undefined.html (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/closest-null-undefined.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/closest-null-undefined.html	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,48 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<undefined id="undefined1">
+    <null id="null1">
+        <target id="target1"></target>
+    </null>
+</undefined>
+
+<null id="null2">
+    <target id="target2"></target>
+</null>
+
+<undefined id="undefined3">
+    <target id="target3"></target>
+</undefined>
+
+<foo>
+    <bar>
+        <target id="target4"></target>
+    <bar>
+</foo>
+
+</body>
+<script>
+description('Test Element.closest() with no argument, null, and undefined.');
+
+shouldThrow('document.getElementById("target1").closest()', '"TypeError: Not enough arguments"');
+shouldBeEqualToString('document.getElementById("target1").closest(null).id', 'null1');
+shouldBeEqualToString('document.getElementById("target1").closest(undefined).id', 'undefined1');
+
+shouldThrow('document.getElementById("target2").closest()', '"TypeError: Not enough arguments"');
+shouldBeEqualToString('document.getElementById("target2").closest(null).id', 'null2');
+shouldBeNull('document.getElementById("target2").closest(undefined)');
+
+shouldThrow('document.getElementById("target3").closest()', '"TypeError: Not enough arguments"');
+shouldBeNull('document.getElementById("target3").closest(null)');
+shouldBeEqualToString('document.getElementById("target3").closest(undefined).id', 'undefined3');
+
+shouldThrow('document.getElementById("target4").closest()', '"TypeError: Not enough arguments"');
+shouldBeNull('document.getElementById("target4").closest(null)');
+shouldBeNull('document.getElementById("target4").closest(undefined)');
+</script>
+<script src=""
+</html>

Added: trunk/LayoutTests/fast/dom/SelectorAPI/matches-definition-expected.txt (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/matches-definition-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/matches-definition-expected.txt	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,17 @@
+Test the definition of Element.matches().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Element.matches is undefined.
+PASS Object.getOwnPropertyDescriptor(Element.prototype, "matches").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Element.prototype, "matches").writable is true
+PASS Element.prototype.matches.length is 1
+PASS Element.webkitMatchesSelector is undefined.
+PASS Object.getOwnPropertyDescriptor(Element.prototype, "webkitMatchesSelector").enumerable is true
+PASS Object.getOwnPropertyDescriptor(Element.prototype, "webkitMatchesSelector").writable is true
+PASS Element.prototype.webkitMatchesSelector.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/SelectorAPI/matches-definition.html (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/matches-definition.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/matches-definition.html	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+</body>
+<script>
+description('Test the definition of Element.matches().');
+
+shouldBeUndefined('Element.matches');
+shouldBeTrue('Object.getOwnPropertyDescriptor(Element.prototype, "matches").enumerable');
+shouldBeTrue('Object.getOwnPropertyDescriptor(Element.prototype, "matches").writable');
+shouldBe('Element.prototype.matches.length', '1');
+
+shouldBeUndefined('Element.webkitMatchesSelector');
+shouldBeTrue('Object.getOwnPropertyDescriptor(Element.prototype, "webkitMatchesSelector").enumerable');
+shouldBeTrue('Object.getOwnPropertyDescriptor(Element.prototype, "webkitMatchesSelector").writable');
+shouldBe('Element.prototype.webkitMatchesSelector.length', '1');
+</script>
+<script src=""
+</html>

Added: trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined-expected.txt (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined-expected.txt	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,27 @@
+Test Element.matches() with no argument, null, and undefined.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.getElementsByTagName("undefined")[0].matches() threw exception TypeError: Not enough arguments.
+PASS document.getElementsByTagName("undefined")[0].matches(undefined) is true
+PASS document.getElementsByTagName("undefined")[0].matches(null) is false
+PASS document.getElementsByTagName("null")[0].matches() threw exception TypeError: Not enough arguments.
+PASS document.getElementsByTagName("null")[0].matches(null) is true
+PASS document.getElementsByTagName("null")[0].matches(undefined) is false
+PASS document.getElementsByTagName("defined")[0].matches() threw exception TypeError: Not enough arguments.
+PASS document.getElementsByTagName("defined")[0].matches(null) is false
+PASS document.getElementsByTagName("defined")[0].matches(undefined) is false
+PASS document.getElementsByTagName("undefined")[0].webkitMatchesSelector() threw exception TypeError: Not enough arguments.
+PASS document.getElementsByTagName("undefined")[0].webkitMatchesSelector(undefined) is true
+PASS document.getElementsByTagName("undefined")[0].webkitMatchesSelector(null) is false
+PASS document.getElementsByTagName("null")[0].webkitMatchesSelector() threw exception TypeError: Not enough arguments.
+PASS document.getElementsByTagName("null")[0].webkitMatchesSelector(null) is true
+PASS document.getElementsByTagName("null")[0].webkitMatchesSelector(undefined) is false
+PASS document.getElementsByTagName("defined")[0].webkitMatchesSelector() threw exception TypeError: Not enough arguments.
+PASS document.getElementsByTagName("defined")[0].webkitMatchesSelector(null) is false
+PASS document.getElementsByTagName("defined")[0].webkitMatchesSelector(undefined) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined.html (0 => 174334)


--- trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined.html	2014-10-06 00:41:09 UTC (rev 174334)
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<undefined></undefined>
+<null></null>
+<defined></defined>
+</body>
+<script>
+description('Test Element.matches() with no argument, null, and undefined.');
+
+shouldThrow('document.getElementsByTagName("undefined")[0].matches()', '"TypeError: Not enough arguments"');
+shouldBeTrue('document.getElementsByTagName("undefined")[0].matches(undefined)');
+shouldBeFalse('document.getElementsByTagName("undefined")[0].matches(null)');
+
+shouldThrow('document.getElementsByTagName("null")[0].matches()', '"TypeError: Not enough arguments"');
+shouldBeTrue('document.getElementsByTagName("null")[0].matches(null)');
+shouldBeFalse('document.getElementsByTagName("null")[0].matches(undefined)');
+
+shouldThrow('document.getElementsByTagName("defined")[0].matches()', '"TypeError: Not enough arguments"');
+shouldBeFalse('document.getElementsByTagName("defined")[0].matches(null)');
+shouldBeFalse('document.getElementsByTagName("defined")[0].matches(undefined)');
+
+shouldThrow('document.getElementsByTagName("undefined")[0].webkitMatchesSelector()', '"TypeError: Not enough arguments"');
+shouldBeTrue('document.getElementsByTagName("undefined")[0].webkitMatchesSelector(undefined)');
+shouldBeFalse('document.getElementsByTagName("undefined")[0].webkitMatchesSelector(null)');
+
+shouldThrow('document.getElementsByTagName("null")[0].webkitMatchesSelector()', '"TypeError: Not enough arguments"');
+shouldBeTrue('document.getElementsByTagName("null")[0].webkitMatchesSelector(null)');
+shouldBeFalse('document.getElementsByTagName("null")[0].webkitMatchesSelector(undefined)');
+
+shouldThrow('document.getElementsByTagName("defined")[0].webkitMatchesSelector()', '"TypeError: Not enough arguments"');
+shouldBeFalse('document.getElementsByTagName("defined")[0].webkitMatchesSelector(null)');
+shouldBeFalse('document.getElementsByTagName("defined")[0].webkitMatchesSelector(undefined)');
+</script>
+<script src=""
+</html>

Modified: trunk/Source/WebCore/ChangeLog (174333 => 174334)


--- trunk/Source/WebCore/ChangeLog	2014-10-06 00:31:05 UTC (rev 174333)
+++ trunk/Source/WebCore/ChangeLog	2014-10-06 00:41:09 UTC (rev 174334)
@@ -1,3 +1,22 @@
+2014-10-05  Benjamin Poulain  <[email protected]>
+
+        Element.matches()'s argument is not supposed to be optional
+        https://bugs.webkit.org/show_bug.cgi?id=137427
+
+        Reviewed by Christophe Dumez.
+
+        The argument was marked as optional, it is not supposed to:
+        https://dom.spec.whatwg.org/#interface-element
+
+        Also update the webkit-prefixed version: webkitMatchesSelector().
+
+        Tests: fast/dom/SelectorAPI/closest-definition.html
+               fast/dom/SelectorAPI/closest-null-undefined.html
+               fast/dom/SelectorAPI/matches-definition.html
+               fast/dom/SelectorAPI/matches-null-undefined.html
+
+        * dom/Element.idl:
+
 2014-10-05  Christophe Dumez  <[email protected]>
 
         Use is<>() / downcast<>() for CachedResource subclasses

Modified: trunk/Source/WebCore/dom/Element.idl (174333 => 174334)


--- trunk/Source/WebCore/dom/Element.idl	2014-10-06 00:31:05 UTC (rev 174333)
+++ trunk/Source/WebCore/dom/Element.idl	2014-10-06 00:41:09 UTC (rev 174334)
@@ -120,9 +120,9 @@
     [RaisesException] Element querySelector(DOMString selectors);
     [RaisesException] NodeList querySelectorAll(DOMString selectors);
 
-    [RaisesException] boolean matches([Default=Undefined] optional DOMString selectors);
+    [RaisesException] boolean matches(DOMString selectors);
     [RaisesException] Element closest(DOMString selectors);    
-    [ImplementedAs=matches, RaisesException] boolean webkitMatchesSelector([Default=Undefined] optional DOMString selectors);
+    [ImplementedAs=matches, RaisesException] boolean webkitMatchesSelector(DOMString selectors);
 
     // ElementTraversal API
     readonly attribute Element firstElementChild;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to