Title: [154005] trunk
Revision
154005
Author
[email protected]
Date
2013-08-13 09:18:43 -0700 (Tue, 13 Aug 2013)

Log Message

HTMLSelectElement.item() does not behave according to specification
https://bugs.webkit.org/show_bug.cgi?id=119738

Reviewed by Darin Adler.

Source/WebCore:

Make HTMLSelectElement.item() behave according to specification:
http://www.w3.org/TR/html51/forms.html#dom-select-item
http://dom.spec.whatwg.org/#dom-htmlcollection-item

Namely, we no longer throw if the offset argument is negative. Also,
the argument is now mandatory.

IE10, Firefox and Blink do not throw when HTMLSelectElement.item() is
called with a negative value (as per the specification).

The argument is mandatory in Firefox and Blink, but optional in IE10
(it returns null when called without argument). This looks like a bug
in IE because other item() getters' argument is usually mandatory in IE
(e.g. NodeList.item()).

Test: fast/dom/HTMLSelectElement/select-element-item-argument.html

* html/HTMLSelectElement.idl:

LayoutTests:

Add a new layout test to check that the HTMLSelectElement.item() indexed getter's
parameter is correctly validated.
Also update fast/dom/non-numeric-values-numeric-parameters.html now that the
argument is mandatory.

* fast/dom/HTMLSelectElement/select-element-item-argument-expected.txt: Added.
* fast/dom/HTMLSelectElement/select-element-item-argument.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 (154004 => 154005)


--- trunk/LayoutTests/ChangeLog	2013-08-13 16:16:04 UTC (rev 154004)
+++ trunk/LayoutTests/ChangeLog	2013-08-13 16:18:43 UTC (rev 154005)
@@ -1,5 +1,22 @@
 2013-08-13  Christophe Dumez  <[email protected]>
 
+        HTMLSelectElement.item() does not behave according to specification
+        https://bugs.webkit.org/show_bug.cgi?id=119738
+
+        Reviewed by Darin Adler.
+
+        Add a new layout test to check that the HTMLSelectElement.item() indexed getter's
+        parameter is correctly validated.
+        Also update fast/dom/non-numeric-values-numeric-parameters.html now that the
+        argument is mandatory.
+
+        * fast/dom/HTMLSelectElement/select-element-item-argument-expected.txt: Added.
+        * fast/dom/HTMLSelectElement/select-element-item-argument.html: Added.
+        * fast/dom/non-numeric-values-numeric-parameters-expected.txt:
+        * fast/dom/script-tests/non-numeric-values-numeric-parameters.js:
+
+2013-08-13  Christophe Dumez  <[email protected]>
+
         On request error, always fire events on the XMLHttpRequestUpload before the XMLHttpRequest
         https://bugs.webkit.org/show_bug.cgi?id=119714
 

Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument-expected.txt (0 => 154005)


--- trunk/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument-expected.txt	2013-08-13 16:18:43 UTC (rev 154005)
@@ -0,0 +1,18 @@
+Tests that the HTMLSelectElement.item() argument is correctly validated.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS select.__proto__ is HTMLSelectElement.prototype
+PASS select.item(0).value is "a"
+PASS select.item(1).value is "b"
+PASS select.item(2).value is "c"
+PASS select.item(3).value is "d"
+PASS select.item(4) is null
+PASS select.item(-1) is null
+PASS select.item(-4294967294).value is "c"
+PASS select.item() threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument.html (0 => 154005)


--- trunk/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/select-element-item-argument.html	2013-08-13 16:18:43 UTC (rev 154005)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="help" href=""
+<script src=""
+</head>
+<body>
+<select id="target">
+  <option value="a">a</option>
+  <option value="b">b</option>
+  <option value="c">c</option>
+  <option value="d">d</option>
+</select>
+
+<script>
+description("Tests that the HTMLSelectElement.item() argument is correctly validated.");
+
+var select = document.getElementById('target');
+shouldBe("select.__proto__", "HTMLSelectElement.prototype");
+
+// getter Node item(unsigned long index);
+shouldBeEqualToString("select.item(0).value", "a");
+shouldBeEqualToString("select.item(1).value", "b");
+shouldBeEqualToString("select.item(2).value", "c");
+shouldBeEqualToString("select.item(3).value", "d");
+shouldBeNull("select.item(4)");
+shouldBeNull("select.item(-1)"); // Offset is too large (after wrapping)
+shouldBeEqualToString("select.item(-4294967294).value", "c"); // Wraps to 2, which is a valid offset.
+shouldThrow("select.item()", "'TypeError: Not enough arguments'");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt (154004 => 154005)


--- trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2013-08-13 16:16:04 UTC (rev 154004)
+++ trunk/LayoutTests/fast/dom/non-numeric-values-numeric-parameters-expected.txt	2013-08-13 16:18:43 UTC (rev 154005)
@@ -31,7 +31,7 @@
 PASS nonNumericPolicy('createHTMLOptionsCollection().add(document.createElement("option"), x)') is 'any type allowed'
 PASS nonNumericPolicy('createHTMLOptionsCollection().remove(x)') is 'any type allowed'
 PASS nonNumericPolicy('createHTMLSelectElement().remove(x)') is 'any type allowed'
-PASS nonNumericPolicy('createHTMLSelectElement().item(x)') is 'any type allowed'
+PASS nonNumericPolicy('createHTMLSelectElement().item(x)') is 'any type allowed (but not omitted)'
 PASS nonNumericPolicy('createHTMLTableElement().insertRow(x)') is 'any type allowed'
 PASS nonNumericPolicy('createHTMLTableElement().deleteRow(x)') is 'any type allowed'
 PASS nonNumericPolicy('createHTMLTableRowElement().insertCell(x)') is 'any type allowed'

Modified: trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js (154004 => 154005)


--- trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2013-08-13 16:16:04 UTC (rev 154004)
+++ trunk/LayoutTests/fast/dom/script-tests/non-numeric-values-numeric-parameters.js	2013-08-13 16:18:43 UTC (rev 154005)
@@ -250,7 +250,7 @@
 // HTMLSelectElement
 
 shouldBe("nonNumericPolicy('createHTMLSelectElement().remove(x)')", "'any type allowed'");
-shouldBe("nonNumericPolicy('createHTMLSelectElement().item(x)')", "'any type allowed'");
+shouldBe("nonNumericPolicy('createHTMLSelectElement().item(x)')", "'any type allowed (but not omitted)'");
 
 // HTMLTableElement
 

Modified: trunk/Source/WebCore/ChangeLog (154004 => 154005)


--- trunk/Source/WebCore/ChangeLog	2013-08-13 16:16:04 UTC (rev 154004)
+++ trunk/Source/WebCore/ChangeLog	2013-08-13 16:18:43 UTC (rev 154005)
@@ -1,5 +1,31 @@
 2013-08-13  Christophe Dumez  <[email protected]>
 
+        HTMLSelectElement.item() does not behave according to specification
+        https://bugs.webkit.org/show_bug.cgi?id=119738
+
+        Reviewed by Darin Adler.
+
+        Make HTMLSelectElement.item() behave according to specification:
+        http://www.w3.org/TR/html51/forms.html#dom-select-item
+        http://dom.spec.whatwg.org/#dom-htmlcollection-item
+
+        Namely, we no longer throw if the offset argument is negative. Also,
+        the argument is now mandatory.
+
+        IE10, Firefox and Blink do not throw when HTMLSelectElement.item() is
+        called with a negative value (as per the specification).
+
+        The argument is mandatory in Firefox and Blink, but optional in IE10
+        (it returns null when called without argument). This looks like a bug
+        in IE because other item() getters' argument is usually mandatory in IE
+        (e.g. NodeList.item()).
+
+        Test: fast/dom/HTMLSelectElement/select-element-item-argument.html
+
+        * html/HTMLSelectElement.idl:
+
+2013-08-13  Christophe Dumez  <[email protected]>
+
         On request error, always fire events on the XMLHttpRequestUpload before the XMLHttpRequest
         https://bugs.webkit.org/show_bug.cgi?id=119714
 

Modified: trunk/Source/WebCore/html/HTMLSelectElement.idl (154004 => 154005)


--- trunk/Source/WebCore/html/HTMLSelectElement.idl	2013-08-13 16:16:04 UTC (rev 154004)
+++ trunk/Source/WebCore/html/HTMLSelectElement.idl	2013-08-13 16:18:43 UTC (rev 154005)
@@ -39,7 +39,7 @@
 #else
     [SetterRaisesException] attribute unsigned long length;
 #endif
-    getter Node item([IsIndex,Default=Undefined] optional unsigned long index);
+    getter Node item(unsigned long index);
     Node namedItem([Default=Undefined] optional DOMString name);
     [ObjCLegacyUnnamedParameters, RaisesException] void add([Default=Undefined] optional HTMLElement element,
                             [Default=Undefined] optional HTMLElement before);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to