Title: [202478] trunk
Revision
202478
Author
[email protected]
Date
2016-06-26 18:29:34 -0700 (Sun, 26 Jun 2016)

Log Message

Regression: HTMLOptionsCollection's named properties have precedence over indexed properties
https://bugs.webkit.org/show_bug.cgi?id=159058
<rdar://problem/26988542>

Reviewed by Ryosuke Niwa.

Source/WebCore:

HTMLOptionsCollection's named properties had precedence over indexed properties,
which is wrong as per:
http://heycam.github.io/webidl/#getownproperty-guts

The reason is that there was a named property getter defined on HTMLOptionsCollection
but no indexed property getter. As a result, HTMLOptionsCollection would fall back to
using HTMLCollection's indexed property getter but HTMLOptionsCollection's named getter
would take precedence. This patch defines an indexed property getter on
HTMLOptionsCollection to fix the problem.

Ideally, HTMLOptionsCollection would have no indexed / named property getters and would
entirely rely on the ones from HTMLCollection. However, our bindings generator currently
has trouble with this and requires HTMLOptionsCollection to have a named getter.

Test: fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html

* html/HTMLOptionsCollection.idl:

LayoutTests:

Add layout test coverage.

* fast/dom/HTMLSelectElement/options-indexed-getter-precedence-expected.txt: Added.
* fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202477 => 202478)


--- trunk/LayoutTests/ChangeLog	2016-06-26 22:31:26 UTC (rev 202477)
+++ trunk/LayoutTests/ChangeLog	2016-06-27 01:29:34 UTC (rev 202478)
@@ -1,3 +1,16 @@
+2016-06-26  Chris Dumez  <[email protected]>
+
+        Regression: HTMLOptionsCollection's named properties have precedence over indexed properties
+        https://bugs.webkit.org/show_bug.cgi?id=159058
+        <rdar://problem/26988542>
+
+        Reviewed by Ryosuke Niwa.
+
+        Add layout test coverage.
+
+        * fast/dom/HTMLSelectElement/options-indexed-getter-precedence-expected.txt: Added.
+        * fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html: Added.
+
 2016-06-26  Javier Fernandez  <[email protected]>
 
         [GTK] Unreviewed test gardening.

Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/options-indexed-getter-precedence-expected.txt (0 => 202478)


--- trunk/LayoutTests/fast/dom/HTMLSelectElement/options-indexed-getter-precedence-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/options-indexed-getter-precedence-expected.txt	2016-06-27 01:29:34 UTC (rev 202478)
@@ -0,0 +1,17 @@
+Test that HTMLOptionsCollection's indexed properties take precedence over named properties
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS options.length is 2
+PASS options[0].value is "option_1"
+PASS options.item(0).value is "option_1"
+PASS options[1].value is "option_2"
+PASS options.item(1).value is "option_2"
+PASS options[2] is undefined.
+PASS options.item(2) is null
+PASS options.namedItem('0').value is "option_2"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html (0 => 202478)


--- trunk/LayoutTests/fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html	2016-06-27 01:29:34 UTC (rev 202478)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<select id="testSelect">
+<option value="option_1">Option 1</option>
+<option name="0" value="option_2">Option 2</option>
+<script>
+description("Test that HTMLOptionsCollection's indexed properties take precedence over named properties");
+
+var options = document.getElementById("testSelect").options;
+shouldBe("options.length", "2");
+shouldBeEqualToString("options[0].value", "option_1"); // Would return option_2 if named properties took precedence over indexed properties.
+shouldBeEqualToString("options.item(0).value", "option_1");
+shouldBeEqualToString("options[1].value", "option_2");
+shouldBeEqualToString("options.item(1).value", "option_2");
+shouldBeUndefined("options[2]");
+shouldBeNull("options.item(2)");
+shouldBeEqualToString("options.namedItem('0').value", "option_2");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (202477 => 202478)


--- trunk/Source/WebCore/ChangeLog	2016-06-26 22:31:26 UTC (rev 202477)
+++ trunk/Source/WebCore/ChangeLog	2016-06-27 01:29:34 UTC (rev 202478)
@@ -1,5 +1,31 @@
 2016-06-26  Chris Dumez  <[email protected]>
 
+        Regression: HTMLOptionsCollection's named properties have precedence over indexed properties
+        https://bugs.webkit.org/show_bug.cgi?id=159058
+        <rdar://problem/26988542>
+
+        Reviewed by Ryosuke Niwa.
+
+        HTMLOptionsCollection's named properties had precedence over indexed properties,
+        which is wrong as per:
+        http://heycam.github.io/webidl/#getownproperty-guts
+
+        The reason is that there was a named property getter defined on HTMLOptionsCollection
+        but no indexed property getter. As a result, HTMLOptionsCollection would fall back to
+        using HTMLCollection's indexed property getter but HTMLOptionsCollection's named getter
+        would take precedence. This patch defines an indexed property getter on
+        HTMLOptionsCollection to fix the problem.
+
+        Ideally, HTMLOptionsCollection would have no indexed / named property getters and would
+        entirely rely on the ones from HTMLCollection. However, our bindings generator currently
+        has trouble with this and requires HTMLOptionsCollection to have a named getter.
+
+        Test: fast/dom/HTMLSelectElement/options-indexed-getter-precedence.html
+
+        * html/HTMLOptionsCollection.idl:
+
+2016-06-26  Chris Dumez  <[email protected]>
+
         Regression(r202262): Infinite loop under searchForLinkRemovingExistingDDLinks()
         https://bugs.webkit.org/show_bug.cgi?id=159122
         <rdar://problem/27014649>

Modified: trunk/Source/WebCore/html/HTMLOptionsCollection.idl (202477 => 202478)


--- trunk/Source/WebCore/html/HTMLOptionsCollection.idl	2016-06-26 22:31:26 UTC (rev 202477)
+++ trunk/Source/WebCore/html/HTMLOptionsCollection.idl	2016-06-27 01:29:34 UTC (rev 202478)
@@ -29,6 +29,8 @@
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
     getter Node namedItem(optional DOMString name);
 #else
+    getter HTMLOptionElement? item(unsigned long index);
+
     // FIXME: Using "undefined" as default parameter value is wrong.
     getter HTMLOptionElement namedItem(optional DOMString name = "undefined");
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to