Title: [106318] trunk
Revision
106318
Author
[email protected]
Date
2012-01-30 18:55:08 -0800 (Mon, 30 Jan 2012)

Log Message

Don't select the next selectable index when deselecting an option in select elements with size set to a value greater than one.
https://bugs.webkit.org/show_bug.cgi?id=76389

Patch by Pablo Flouret <[email protected]> on 2012-01-30
Reviewed by Kent Tamura.

This behavior matches the rest of the browsers.

Source/WebCore:

Test: fast/forms/select/option-selecting.html

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

LayoutTests:

* fast/forms/select/option-selecting-expected.txt: Added.
* fast/forms/select/option-selecting.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106317 => 106318)


--- trunk/LayoutTests/ChangeLog	2012-01-31 02:43:37 UTC (rev 106317)
+++ trunk/LayoutTests/ChangeLog	2012-01-31 02:55:08 UTC (rev 106318)
@@ -1,3 +1,15 @@
+2012-01-30  Pablo Flouret  <[email protected]>
+
+        Don't select the next selectable index when deselecting an option in select elements with size set to a value greater than one.
+        https://bugs.webkit.org/show_bug.cgi?id=76389
+
+        Reviewed by Kent Tamura.
+
+        This behavior matches the rest of the browsers.
+
+        * fast/forms/select/option-selecting-expected.txt: Added.
+        * fast/forms/select/option-selecting.html: Added.
+
 2012-01-30  Levi Weintraub  <[email protected]>
 
         Layout Test plugins/crash-restoring-plugin-page-from-page-cache.html is slow on Chromium

Added: trunk/LayoutTests/fast/forms/select/option-selecting-expected.txt (0 => 106318)


--- trunk/LayoutTests/fast/forms/select/option-selecting-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select/option-selecting-expected.txt	2012-01-31 02:55:08 UTC (rev 106318)
@@ -0,0 +1,51 @@
+Test the behavior of selecting and deselecting options in <select> elements.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+ListBox with no size attribute specified.
+PASS menuListBoxNoSize.selectedIndex is 1
+PASS menuListBoxNoSize.options[1].selected is true
+Setting menuListBoxNoSize.options[2].selected = true
+Setting menuListBoxNoSize.options[2].selected = false
+PASS menuListBoxNoSize.selectedIndex is 1
+PASS menuListBoxNoSize.options[1].selected is true
+
+ListBox with size=1 attribute.
+PASS menuListBoxSize1.selectedIndex is 1
+PASS menuListBoxSize1.options[1].selected is true
+Setting menuListBoxSize1.options[2].selected = true
+Setting menuListBoxSize1.options[2].selected = false
+PASS menuListBoxSize1.selectedIndex is 1
+PASS menuListBoxSize1.options[1].selected is true
+
+ListBox with size=3 attribute.
+PASS menuListBoxSize3.selectedIndex is -1
+Setting menuListBoxSize3.options[1].selected = true
+Setting menuListBoxSize3.options[1].selected = false
+PASS menuListBoxSize3.selectedIndex is -1
+PASS menuListBoxSize3.options[0].selected is false
+PASS menuListBoxSize3.options[1].selected is false
+Setting menuListBoxSize3.selectedIndex = 1
+PASS menuListBoxSize3.selectedIndex is 1
+PASS menuListBoxSize3.options[1].selected is true
+Setting menuListBoxSize3.selectedIndex = -1
+PASS menuListBoxSize3.selectedIndex is -1
+PASS menuListBoxSize3.options[0].selected is false
+PASS menuListBoxSize3.options[1].selected is false
+
+ListBox with multiple attribute.
+PASS multipleListBox.selectedIndex is -1
+Setting multipleListBox.options[1].selected = true
+Setting multipleListBox.options[1].selected = false
+PASS multipleListBox.selectedIndex is -1
+PASS multipleListBox.options[0].selected is false
+PASS multipleListBox.options[1].selected is false
+Setting multipleListBox.options[1].selected = true
+Setting multipleListBox.options[2].selected = true
+PASS multipleListBox.options[1].selected is true
+PASS multipleListBox.options[2].selected is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/select/option-selecting.html (0 => 106318)


--- trunk/LayoutTests/fast/forms/select/option-selecting.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select/option-selecting.html	2012-01-31 02:55:08 UTC (rev 106318)
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<form style="visibility: hidden">
+    <select name=menuListBoxNoSize>
+        <option disabled>A</option>
+        <option>B</option>
+        <option>C</option>
+    </select>
+    <select name=menuListBoxSize1 size=1>
+        <option disabled>A</option>
+        <option>B</option>
+        <option>C</option>
+    </select>
+    <select name=menuListBoxSize3 size=3>
+        <option>A</option>
+        <option>B</option>
+        <option>C</option>
+    </select>
+    <select multiple name=multipleListBox>
+        <option>X</option>
+        <option>Y</option>
+        <option>Z</option>
+    </select>
+</form>
+<script>
+description("Test the behavior of selecting and deselecting options in &lt;select&gt; elements.");
+
+var menuListBoxNoSize = document.forms[0].elements.menuListBoxNoSize;
+debug("ListBox with no size attribute specified.");
+shouldBe("menuListBoxNoSize.selectedIndex", "1");
+shouldBe("menuListBoxNoSize.options[1].selected", "true");
+debug("Setting menuListBoxNoSize.options[2].selected = true");
+menuListBoxNoSize.options[2].selected = true;
+debug("Setting menuListBoxNoSize.options[2].selected = false");
+menuListBoxNoSize.options[2].selected = false;
+shouldBe("menuListBoxNoSize.selectedIndex", "1");
+shouldBe("menuListBoxNoSize.options[1].selected", "true");
+
+
+var menuListBoxSize1 = document.forms[0].elements.menuListBoxSize1;
+debug("\nListBox with size=1 attribute.");
+shouldBe("menuListBoxSize1.selectedIndex", "1");
+shouldBe("menuListBoxSize1.options[1].selected", "true");
+debug("Setting menuListBoxSize1.options[2].selected = true");
+menuListBoxSize1.options[2].selected = true;
+debug("Setting menuListBoxSize1.options[2].selected = false");
+menuListBoxSize1.options[2].selected = false;
+shouldBe("menuListBoxSize1.selectedIndex", "1");
+shouldBe("menuListBoxSize1.options[1].selected", "true");
+
+
+var menuListBoxSize3 = document.forms[0].elements.menuListBoxSize3;
+debug("\nListBox with size=3 attribute.");
+shouldBe("menuListBoxSize3.selectedIndex", "-1");
+debug("Setting menuListBoxSize3.options[1].selected = true");
+menuListBoxSize3.options[1].selected = true;
+debug("Setting menuListBoxSize3.options[1].selected = false");
+menuListBoxSize3.options[1].selected = false;
+shouldBe("menuListBoxSize3.selectedIndex", "-1");
+shouldBe("menuListBoxSize3.options[0].selected", "false");
+shouldBe("menuListBoxSize3.options[1].selected", "false");
+
+debug("Setting menuListBoxSize3.selectedIndex = 1");
+menuListBoxSize3.selectedIndex = 1;
+shouldBe("menuListBoxSize3.selectedIndex", "1");
+shouldBe("menuListBoxSize3.options[1].selected", "true");
+
+menuListBoxSize3.selectedIndex = -1;
+debug("Setting menuListBoxSize3.selectedIndex = -1");
+shouldBe("menuListBoxSize3.selectedIndex", "-1");
+shouldBe("menuListBoxSize3.options[0].selected", "false");
+shouldBe("menuListBoxSize3.options[1].selected", "false");
+
+
+var multipleListBox = document.forms[0].elements.multipleListBox;
+debug("\nListBox with multiple attribute.");
+shouldBe("multipleListBox.selectedIndex", "-1");
+debug("Setting multipleListBox.options[1].selected = true");
+multipleListBox.options[1].selected = true;
+debug("Setting multipleListBox.options[1].selected = false");
+multipleListBox.options[1].selected = false;
+shouldBe("multipleListBox.selectedIndex", "-1");
+shouldBe("multipleListBox.options[0].selected", "false");
+shouldBe("multipleListBox.options[1].selected", "false");
+debug("Setting multipleListBox.options[1].selected = true");
+multipleListBox.options[1].selected = true;
+debug("Setting multipleListBox.options[2].selected = true");
+multipleListBox.options[2].selected = true;
+shouldBe("multipleListBox.options[1].selected", "true");
+shouldBe("multipleListBox.options[2].selected", "true");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (106317 => 106318)


--- trunk/Source/WebCore/ChangeLog	2012-01-31 02:43:37 UTC (rev 106317)
+++ trunk/Source/WebCore/ChangeLog	2012-01-31 02:55:08 UTC (rev 106318)
@@ -1,3 +1,17 @@
+2012-01-30  Pablo Flouret  <[email protected]>
+
+        Don't select the next selectable index when deselecting an option in select elements with size set to a value greater than one.
+        https://bugs.webkit.org/show_bug.cgi?id=76389
+
+        Reviewed by Kent Tamura.
+
+        This behavior matches the rest of the browsers.
+
+        Test: fast/forms/select/option-selecting.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::optionSelectionStateChanged):
+
 2012-01-30  Anders Carlsson  <[email protected]>
 
         Scrollbars don't show when scrolling on the scrolling thread

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (106317 => 106318)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2012-01-31 02:43:37 UTC (rev 106317)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2012-01-31 02:55:08 UTC (rev 106318)
@@ -767,8 +767,10 @@
     ASSERT(option->ownerSelectElement() == this);
     if (optionIsSelected)
         selectOption(option->index());
+    else if (!usesMenuList())
+        selectOption(-1);
     else
-        selectOption(m_multiple ? -1 : nextSelectableListIndex(-1));
+        selectOption(nextSelectableListIndex(-1));
 }
 
 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to