Title: [86744] trunk
Revision
86744
Author
[email protected]
Date
2011-05-18 02:33:42 -0700 (Wed, 18 May 2011)

Log Message

2011-05-18  Kent Tamura  <[email protected]>

        Reviewed by Hajime Morita.

        valueMissing validity for <select> is lame when selecting a value by a key operation
        https://bugs.webkit.org/show_bug.cgi?id=61021

        Add test cases for the bug.

        * fast/forms/ValidityState-valueMissing-002-expected.txt:
        * fast/forms/ValidityState-valueMissing-002.html:
2011-05-18  Kent Tamura  <[email protected]>

        Reviewed by Hajime Morita.

        valueMissing validity for <select> is lame when selecting a value by a key operation
        https://bugs.webkit.org/show_bug.cgi?id=61021

        We missed updating validity in case that SelectElement::defaultEventHandler
        update selections.  So, SelectElement::setSelectedIndex() updates validity.

        * dom/SelectElement.cpp:
        (WebCore::SelectElement::setSelectedIndex): Call SelectElement::updateValidity().
        * html/HTMLSelectElement.cpp:
        (WebCore::HTMLSelectElement::setSelectedIndex):
          Remove unnecessary setNeedsValidityCheck() call.
          SelectElement::setSlectedIndex() calls it.
        (WebCore::HTMLSelectElement::setSelectedIndexByUser): ditto.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (86743 => 86744)


--- trunk/LayoutTests/ChangeLog	2011-05-18 09:31:32 UTC (rev 86743)
+++ trunk/LayoutTests/ChangeLog	2011-05-18 09:33:42 UTC (rev 86744)
@@ -1,3 +1,15 @@
+2011-05-18  Kent Tamura  <[email protected]>
+
+        Reviewed by Hajime Morita.
+
+        valueMissing validity for <select> is lame when selecting a value by a key operation
+        https://bugs.webkit.org/show_bug.cgi?id=61021
+
+        Add test cases for the bug.
+
+        * fast/forms/ValidityState-valueMissing-002-expected.txt:
+        * fast/forms/ValidityState-valueMissing-002.html:
+
 2011-05-18  Kristóf Kosztyó  <[email protected]>
 
         Reviewed by Csaba Osztrogonác.

Modified: trunk/LayoutTests/fast/forms/ValidityState-valueMissing-002-expected.txt (86743 => 86744)


--- trunk/LayoutTests/fast/forms/ValidityState-valueMissing-002-expected.txt	2011-05-18 09:31:32 UTC (rev 86743)
+++ trunk/LayoutTests/fast/forms/ValidityState-valueMissing-002-expected.txt	2011-05-18 09:33:42 UTC (rev 86744)
@@ -13,7 +13,14 @@
 PASS valueMissingFor("select-without-fake-placeholder-multiple") is false
 PASS valueMissingFor("select-with-fake-placeholder-size2-multiple") is false
 PASS valueMissingFor("select-without-fake-placeholder-size2-multiple") is false
+Updating valueMissing state by a key input:
+PASS valueMissingFor("select-selecting-by-key") is true
+PASS select.value is "a"
+PASS valueMissingFor("select-selecting-by-key") is false
+PASS valueMissingFor("select-selecting-by-key-2") is true
+PASS select.value is "a"
+PASS valueMissingFor("select-selecting-by-key-2") is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
-         
+

Modified: trunk/LayoutTests/fast/forms/ValidityState-valueMissing-002.html (86743 => 86744)


--- trunk/LayoutTests/fast/forms/ValidityState-valueMissing-002.html	2011-05-18 09:31:32 UTC (rev 86743)
+++ trunk/LayoutTests/fast/forms/ValidityState-valueMissing-002.html	2011-05-18 09:33:42 UTC (rev 86744)
@@ -8,6 +8,7 @@
 <body>
 <p id="description"></p>
 <div id="console"></div>
+<div id=parent>
 <input id="input" name="victim" value="something" required/>
 <textarea id="textarea" name="victim" required>something</textarea>
 <select id="select-with-placeholder" name="victim" required>
@@ -42,6 +43,15 @@
   <option value="X" selected>X</option>
   <option value="" />
 </select>
+<select id=select-selecting-by-key required>
+  <option value="" selected/>
+  <option>a</option>
+</select>
+<select id=select-selecting-by-key-2 required>
+  <option value="" selected/>
+  <option accesskey="1">a</option>
+</select>
+</div>
 <script language="_javascript_" type="text/_javascript_">
     function valueMissingFor(id) {
         return document.getElementById(id).validity.valueMissing;
@@ -49,8 +59,6 @@
 
     description("This test checks validity.valueMissing with some values or options with some values selected.");
 
-    v = document.getElementsByName("victim");
-
     shouldBeFalse('valueMissingFor("input")');
     shouldBeFalse('valueMissingFor("textarea")');
     shouldBeFalse('valueMissingFor("select-with-placeholder")');
@@ -62,6 +70,35 @@
     shouldBeFalse('valueMissingFor("select-with-fake-placeholder-size2-multiple")');
     shouldBeFalse('valueMissingFor("select-without-fake-placeholder-size2-multiple")');
 
+    // Need to use eventSender instead of initKeyboardEvent() because we can't
+    // make an event which returns a correct value for keyCode by initKeyboardEvent().
+    if (window.eventSender) {
+        debug("Updating valueMissing state by a key input:")
+        // Select by type-ahead.
+        var select = document.getElementById("select-selecting-by-key");
+        shouldBeTrue('valueMissingFor("select-selecting-by-key")');
+        select.focus();
+        eventSender.keyDown("a");
+        shouldBe('select.value', '"a"');
+        shouldBeFalse('valueMissingFor("select-selecting-by-key")');
+
+        // Select by accesskey.
+        select = document.getElementById("select-selecting-by-key-2");
+        shouldBeTrue('valueMissingFor("select-selecting-by-key-2")');
+        select.focus();
+        var modifiers;
+        if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
+            modifiers = ['ctrlKey', 'altKey'];
+        else
+            modifiers = ['altKey'];
+        eventSender.keyDown("1", modifiers);
+        shouldBe('select.value', '"a"');
+        shouldBeFalse('valueMissingFor("select-selecting-by-key-2")');
+    } else {
+        debug('There are tests using eventSender.');
+    }
+
+    document.body.removeChild(document.getElementById('parent'));
     var successfullyParsed = true;
 </script>
 <script src=""

Modified: trunk/Source/WebCore/ChangeLog (86743 => 86744)


--- trunk/Source/WebCore/ChangeLog	2011-05-18 09:31:32 UTC (rev 86743)
+++ trunk/Source/WebCore/ChangeLog	2011-05-18 09:33:42 UTC (rev 86744)
@@ -1,3 +1,21 @@
+2011-05-18  Kent Tamura  <[email protected]>
+
+        Reviewed by Hajime Morita.
+
+        valueMissing validity for <select> is lame when selecting a value by a key operation
+        https://bugs.webkit.org/show_bug.cgi?id=61021
+
+        We missed updating validity in case that SelectElement::defaultEventHandler
+        update selections.  So, SelectElement::setSelectedIndex() updates validity.
+
+        * dom/SelectElement.cpp:
+        (WebCore::SelectElement::setSelectedIndex): Call SelectElement::updateValidity().
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::setSelectedIndex):
+          Remove unnecessary setNeedsValidityCheck() call.
+          SelectElement::setSlectedIndex() calls it.
+        (WebCore::HTMLSelectElement::setSelectedIndexByUser): ditto.
+
 2011-05-17  Mikhail Naganov  <[email protected]>
 
         Reviewed by Pavel Feldman.

Modified: trunk/Source/WebCore/dom/SelectElement.cpp (86743 => 86744)


--- trunk/Source/WebCore/dom/SelectElement.cpp	2011-05-18 09:31:32 UTC (rev 86743)
+++ trunk/Source/WebCore/dom/SelectElement.cpp	2011-05-18 09:33:42 UTC (rev 86744)
@@ -395,6 +395,7 @@
         }
     }
 
+    toSelectElement(element)->updateValidity();
     if (Frame* frame = element->document()->frame())
         frame->page()->chrome()->client()->formStateDidChange(element);
 }

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (86743 => 86744)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2011-05-18 09:31:32 UTC (rev 86743)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2011-05-18 09:33:42 UTC (rev 86744)
@@ -84,7 +84,6 @@
 void HTMLSelectElement::setSelectedIndex(int optionIndex, bool deselect)
 {
     SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, false, false);
-    setNeedsValidityCheck();
 }
 
 void HTMLSelectElement::setSelectedIndexByUser(int optionIndex, bool deselect, bool fireOnChangeNow, bool allowMultipleSelection)
@@ -107,7 +106,6 @@
         return;
     
     SelectElement::setSelectedIndex(m_data, this, optionIndex, deselect, fireOnChangeNow, true);
-    setNeedsValidityCheck();
 }
 
 bool HTMLSelectElement::hasPlaceholderLabelOption() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to