Title: [207276] trunk
Revision
207276
Author
cdu...@apple.com
Date
2016-10-12 21:13:49 -0700 (Wed, 12 Oct 2016)

Log Message

Update HTMLSelectElement::recalcListItems() to ignore nested optgroup elements
https://bugs.webkit.org/show_bug.cgi?id=163358

Reviewed by Kent Tamura.

Source/WebCore:

Update HTMLSelectElement::recalcListItems() to ignore nested optgroup elements.
As per the specification, we only want optgroup elements that are direct
children of the select element. This also matches the behavior of Chrome.

Test: fast/dom/HTMLSelectElement/nested-optgroup.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::recalcListItems):

LayoutTests:

Add layout test coverage.

* fast/dom/HTMLSelectElement/nested-optgroup-expected.txt: Added.
* fast/dom/HTMLSelectElement/nested-optgroup.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207275 => 207276)


--- trunk/LayoutTests/ChangeLog	2016-10-13 03:48:54 UTC (rev 207275)
+++ trunk/LayoutTests/ChangeLog	2016-10-13 04:13:49 UTC (rev 207276)
@@ -1,3 +1,15 @@
+2016-10-12  Chris Dumez  <cdu...@apple.com>
+
+        Update HTMLSelectElement::recalcListItems() to ignore nested optgroup elements
+        https://bugs.webkit.org/show_bug.cgi?id=163358
+
+        Reviewed by Kent Tamura.
+
+        Add layout test coverage.
+
+        * fast/dom/HTMLSelectElement/nested-optgroup-expected.txt: Added.
+        * fast/dom/HTMLSelectElement/nested-optgroup.html: Added.
+
 2016-10-12  Zalan Bujtas  <za...@apple.com>
 
         RenderRubyRun should not mark child renderers dirty at the end of layout.

Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/nested-optgroup-expected.txt (0 => 207276)


--- trunk/LayoutTests/fast/dom/HTMLSelectElement/nested-optgroup-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/nested-optgroup-expected.txt	2016-10-13 04:13:49 UTC (rev 207276)
@@ -0,0 +1,10 @@
+Test that options in nested optgroup elements cannot be selected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS select.value is "PASS"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLSelectElement/nested-optgroup.html (0 => 207276)


--- trunk/LayoutTests/fast/dom/HTMLSelectElement/nested-optgroup.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLSelectElement/nested-optgroup.html	2016-10-13 04:13:49 UTC (rev 207276)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<body>
+<select id="testSelect">
+  <option>FAIL</option>
+  <optgroup id="topGroup" label="Top group"></optgroup>
+  <option>PASS</option>
+</select>
+<script src=""
+<script>
+description("Test that options in nested optgroup elements cannot be selected.");
+
+var select = document.getElementById("testSelect");
+var topgroup = document.getElementById("topGroup");
+
+var nestedGroup = document.createElement("optgroup");
+nestedGroup.label = "Nested group";
+var option = document.createElement("option");
+option.appendChild(document.createTextNode("FAIL"));
+nestedGroup.appendChild(option);
+topGroup.appendChild(nestedGroup);
+
+select.selectedIndex = 1;
+shouldBeEqualToString("select.value", "PASS");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (207275 => 207276)


--- trunk/Source/WebCore/ChangeLog	2016-10-13 03:48:54 UTC (rev 207275)
+++ trunk/Source/WebCore/ChangeLog	2016-10-13 04:13:49 UTC (rev 207276)
@@ -1,3 +1,19 @@
+2016-10-12  Chris Dumez  <cdu...@apple.com>
+
+        Update HTMLSelectElement::recalcListItems() to ignore nested optgroup elements
+        https://bugs.webkit.org/show_bug.cgi?id=163358
+
+        Reviewed by Kent Tamura.
+
+        Update HTMLSelectElement::recalcListItems() to ignore nested optgroup elements.
+        As per the specification, we only want optgroup elements that are direct
+        children of the select element. This also matches the behavior of Chrome.
+
+        Test: fast/dom/HTMLSelectElement/nested-optgroup.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::recalcListItems):
+
 2016-10-12  Zalan Bujtas  <za...@apple.com>
 
         RenderRubyRun should not mark child renderers dirty at the end of layout.

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (207275 => 207276)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2016-10-13 03:48:54 UTC (rev 207275)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2016-10-13 04:13:49 UTC (rev 207276)
@@ -770,10 +770,8 @@
         }
         HTMLElement& current = downcast<HTMLElement>(*currentElement);
 
-        // optgroup tags may not nest. However, both FireFox and IE will
-        // flatten the tree automatically, so we follow suit.
-        // (http://www.w3.org/TR/html401/interact/forms.html#h-17.6)
-        if (is<HTMLOptGroupElement>(current)) {
+        // Only consider optgroup elements that are direct children of the select element.
+        if (is<HTMLOptGroupElement>(current) && current.parentNode() == this) {
             m_listItems.append(&current);
             if (Element* nextElement = ElementTraversal::firstWithin(current)) {
                 currentElement = nextElement;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to