- Revision
- 154012
- Author
- [email protected]
- Date
- 2013-08-13 10:58:53 -0700 (Tue, 13 Aug 2013)
Log Message
NodeList.item() does not behave according to specification
https://bugs.webkit.org/show_bug.cgi?id=119722
Reviewed by Darin Adler.
Source/WebCore:
Make NodeList.item() indexed getter behave according to specification:
http://dom.spec.whatwg.org/#nodelist
Namely, we no longer throw if the index is negative (meaning the
[IsIndex] extended attribute is dropped) and the argument is now
mandatory.
This behavior is consistent with both IE10 and Firefox and since
recently Blink.
Test: fast/dom/nodelist-item-parameter.html
* dom/NodeList.idl:
LayoutTests:
Add a layout test to check that the NodeList.item() indexed getter's
argument is properly validated. Also, update the following test case now
that the argument is mandatory:
fast/dom/non-numeric-values-numeric-parameters.html
* fast/dom/nodelist-item-parameter-expected.txt: Added.
* fast/dom/nodelist-item-parameter.html: Added.
* fast/dom/non-numeric-values-numeric-parameters-expected.txt:
* fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (154011 => 154012)
--- trunk/LayoutTests/ChangeLog 2013-08-13 17:49:52 UTC (rev 154011)
+++ trunk/LayoutTests/ChangeLog 2013-08-13 17:58:53 UTC (rev 154012)
@@ -1,3 +1,20 @@
+2013-08-13 Christophe Dumez <[email protected]>
+
+ NodeList.item() does not behave according to specification
+ https://bugs.webkit.org/show_bug.cgi?id=119722
+
+ Reviewed by Darin Adler.
+
+ Add a layout test to check that the NodeList.item() indexed getter's
+ argument is properly validated. Also, update the following test case now
+ that the argument is mandatory:
+ fast/dom/non-numeric-values-numeric-parameters.html
+
+ * fast/dom/nodelist-item-parameter-expected.txt: Added.
+ * fast/dom/nodelist-item-parameter.html: Added.
+ * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
+ * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
+
2013-08-13 Allan Sandfeld Jensen <[email protected]>
REGRESSION(SUBPIXEL_LAYOUT) Composited layers can cause one pixel shifts
Added: trunk/LayoutTests/fast/dom/nodelist-item-parameter-expected.txt (0 => 154012)
--- trunk/LayoutTests/fast/dom/nodelist-item-parameter-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/nodelist-item-parameter-expected.txt 2013-08-13 17:58:53 UTC (rev 154012)
@@ -0,0 +1,16 @@
+Tests that the NodeList.item() argument is correctly validated.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS nodeList.__proto__ is NodeList.prototype
+PASS nodeList.item(0).id is "a"
+PASS nodeList.item(1).id is "b"
+PASS nodeList.item(2) is null
+PASS nodeList.item(-1) is null
+PASS nodeList.item(-4294967295).id is "b"
+PASS nodeList.item() threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/nodelist-item-parameter.html (0 => 154012)
--- trunk/LayoutTests/fast/dom/nodelist-item-parameter.html (rev 0)
+++ trunk/LayoutTests/fast/dom/nodelist-item-parameter.html 2013-08-13 17:58:53 UTC (rev 154012)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="help" href=""
+<script src=""
+</head>
+<body>
+<span id="target">
+ <div id="a"></div>
+ <div id="b"></div>
+</span>
+<script>
+description("Tests that the NodeList.item() argument is correctly validated.");
+
+var nodeList = document.getElementById("target").querySelectorAll('div');
+shouldBe("nodeList.__proto__", "NodeList.prototype");
+
+shouldBeEqualToString("nodeList.item(0).id", "a");
+shouldBeEqualToString("nodeList.item(1).id", "b");
+shouldBeNull("nodeList.item(2)");
+shouldBeNull("nodeList.item(-1)");
+shouldBeEqualToString("nodeList.item(-4294967295).id", "b"); // Wraps to 1.
+shouldThrow("nodeList.item()", "'TypeError: Not enough arguments'");
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt (154011 => 154012)
--- trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt 2013-08-13 17:49:52 UTC (rev 154011)
+++ trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt 2013-08-13 17:58:53 UTC (rev 154012)
@@ -50,7 +50,7 @@
PASS nonNumericPolicy('document.createEvent("MouseEvent").initMouseEvent("a", false, false, null, 0, 0, 0, 0, 0, false, false, false, false, x, null)') is 'any type allowed'
PASS nonNumericPolicy('document.body.attributes.item(x)') is 'any type allowed'
PASS nonNumericPolicy('document.createNodeIterator(document, x, null, false)') is 'any type allowed'
-PASS nonNumericPolicy('document.getElementsByTagName("div").item(x)') is 'any type allowed'
+PASS nonNumericPolicy('document.getElementsByTagName("div").item(x)') is 'any type allowed (but not omitted)'
PASS nonNumericPolicy('document.createRange().setStart(document, x)') is 'any type allowed'
PASS nonNumericPolicy('document.createRange().setEnd(document, x)') is 'any type allowed'
PASS nonNumericPolicy('document.createRange().comparePoint(document, x)') is 'any type allowed'
Modified: trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js (154011 => 154012)
--- trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js 2013-08-13 17:49:52 UTC (rev 154011)
+++ trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js 2013-08-13 17:58:53 UTC (rev 154012)
@@ -299,7 +299,7 @@
// NodeList
-shouldBe("nonNumericPolicy('document.getElementsByTagName(\"div\").item(x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('document.getElementsByTagName(\"div\").item(x)')", "'any type allowed (but not omitted)'");
// Range
Modified: trunk/Source/WebCore/ChangeLog (154011 => 154012)
--- trunk/Source/WebCore/ChangeLog 2013-08-13 17:49:52 UTC (rev 154011)
+++ trunk/Source/WebCore/ChangeLog 2013-08-13 17:58:53 UTC (rev 154012)
@@ -1,3 +1,24 @@
+2013-08-13 Christophe Dumez <[email protected]>
+
+ NodeList.item() does not behave according to specification
+ https://bugs.webkit.org/show_bug.cgi?id=119722
+
+ Reviewed by Darin Adler.
+
+ Make NodeList.item() indexed getter behave according to specification:
+ http://dom.spec.whatwg.org/#nodelist
+
+ Namely, we no longer throw if the index is negative (meaning the
+ [IsIndex] extended attribute is dropped) and the argument is now
+ mandatory.
+
+ This behavior is consistent with both IE10 and Firefox and since
+ recently Blink.
+
+ Test: fast/dom/nodelist-item-parameter.html
+
+ * dom/NodeList.idl:
+
2013-08-13 Anders Carlsson <[email protected]>
Fix build.
Modified: trunk/Source/WebCore/dom/NodeList.idl (154011 => 154012)
--- trunk/Source/WebCore/dom/NodeList.idl 2013-08-13 17:49:52 UTC (rev 154011)
+++ trunk/Source/WebCore/dom/NodeList.idl 2013-08-13 17:58:53 UTC (rev 154012)
@@ -23,7 +23,7 @@
SkipVTableValidation
] interface NodeList {
- getter Node item([IsIndex,Default=Undefined] optional unsigned long index);
+ getter Node item(unsigned long index);
getter (Node or unsigned long) (DOMString name);
readonly attribute unsigned long length;