2006-12-05 Kirby White <KWhiteRight@gmail.com>
authorap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 10:23:25 +0000 (10:23 +0000)
committerap <ap@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 10:23:25 +0000 (10:23 +0000)
        Reviewed and landed by Alexey.

        http://bugs.webkit.org/show_bug.cgi?id=11681
        Don't select the first option when resetting a listbox-style form
        control (i.e., a multi-select control or one with size > 1) that
        has no default selection.

        Test: fast/dom/HTMLSelectElement/listbox-select-reset.html

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@18019 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLSelectElement/listbox-select-reset-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLSelectElement/listbox-select-reset.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLSelectElement.cpp

index 0c000d684315686384e9843b08626cb3d7708c57..b3e2987e679f7f61d21f1470fde63cca68cb1398 100644 (file)
@@ -1,3 +1,10 @@
+2006-12-05  Kirby White  <KWhiteRight@gmail.com>
+
+        Reviewed and landed by Alexey.
+
+        * fast/dom/HTMLSelectElement/listbox-select-reset-expected.txt: Added.
+        * fast/dom/HTMLSelectElement/listbox-select-reset.html: Added.
+
 2006-12-05  Alexey Proskuryakov  <ap@webkit.org>
 
         Reviewed by Rob.
diff --git a/LayoutTests/fast/dom/HTMLSelectElement/listbox-select-reset-expected.txt b/LayoutTests/fast/dom/HTMLSelectElement/listbox-select-reset-expected.txt
new file mode 100644 (file)
index 0000000..b54dc7e
--- /dev/null
@@ -0,0 +1,10 @@
+  
+This test verifies that list-box-style select form controls with no "selected" attributes are properly cleared when reset.
+
+You should see two element IDs below, and the word "SUCCESS" twice:
+
+multiSelectElement: SUCCESS
+
+singleSelectElement: SUCCESS
+
+
diff --git a/LayoutTests/fast/dom/HTMLSelectElement/listbox-select-reset.html b/LayoutTests/fast/dom/HTMLSelectElement/listbox-select-reset.html
new file mode 100644 (file)
index 0000000..676346f
--- /dev/null
@@ -0,0 +1,42 @@
+<head>
+</head>
+<body>
+<form>
+<select id="multiSelectElement" multiple="mulitple">
+<option>one</option>
+<option>two</option>
+<option>three</option>
+</select>
+<select id="singleSelectElement" size="3">
+<option>one</option>
+<option>two</option>
+<option>three</option>
+</select>
+<input id="resetButton" type="reset">
+</form>
+<p>This test verifies that list-box-style select form controls with no 
+"selected" attributes are properly cleared when reset.
+<p>You should see two element IDs below, and the word "SUCCESS" twice:
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+var button = document.getElementById("resetButton");
+
+function test(elementId)
+{
+    var testSelectElement = document.getElementById(elementId);
+    var result = "FAILED";
+    if (testSelectElement.selectedIndex == -1)
+    {
+        testSelectElement.selectedIndex = 1;
+        button.click();
+        if (testSelectElement.selectedIndex == -1)
+            result = "SUCCESS";
+    }
+    document.writeln("<p>" + elementId + ": " + result + "</p>");
+}
+test("multiSelectElement");
+test("singleSelectElement");
+</script>
+</body>
+</html>
index f2e6ff8c8ee5a981a696df8dec1e643ab81d02b1..c3612bc211fc7936bb44d6905ef0fd7b08eb7ef2 100644 (file)
@@ -1,3 +1,17 @@
+2006-12-05  Kirby White  <KWhiteRight@gmail.com>
+
+        Reviewed and landed by Alexey.
+
+        http://bugs.webkit.org/show_bug.cgi?id=11681
+        Don't select the first option when resetting a listbox-style form 
+        control (i.e., a multi-select control or one with size > 1) that
+        has no default selection.
+
+        Test: fast/dom/HTMLSelectElement/listbox-select-reset.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::reset):
+
 2006-12-05  Lars Naesbye Christensen  <larsnaesbye@stud.ku.dk>
 
         Reviewed and landed by Alexey.
index 4f4f99372b9a2b39326e6a44c298a7f5dd0bab08..eb17dd1fedd35f3e5eabeb2af0085d006960de42 100644 (file)
@@ -502,7 +502,7 @@ void HTMLSelectElement::reset()
                 firstOption = option;
         }
     }
-    if (!optionSelected && firstOption)
+    if (!optionSelected && firstOption && usesMenuList())
         firstOption->setSelected(true);
     setChanged(true);
     m_lastOnChangeIndex = -1;