"input" event is not fired when changing a select element's value
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Mar 2014 15:09:33 +0000 (15:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Mar 2014 15:09:33 +0000 (15:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117526

Patch by Lorenzo Tilve <ltilve@igalia.com> on 2014-03-20
Reviewed by Antti Koivisto.

Source/WebCore:

Add a call to dispatch input event when listbox or menulist
values are modified.

According to the spec: "When the user agent is to send select update
notifications, queue a task to first fire a simple even that bubbles
named input at the select element, and then fire a simple event that
bubbles named change at the select element, using the user interaction
task source as the task source."

Tests: fast/forms/select/listbox-oninput-fired.html
       fast/forms/select/menulist-oninput-fired.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::listBoxOnChange):
(WebCore::HTMLSelectElement::dispatchChangeEventForMenuList):

LayoutTests:

Add tests to verify that input event is dispatched when listbox
or menulist values are modified.

* fast/forms/select/listbox-oninput-fired-expected.txt: Added.
* fast/forms/select/listbox-oninput-fired.html: Added.
* fast/forms/select/menulist-oninput-fired-expected.txt: Added.
* fast/forms/select/menulist-oninput-fired.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/select/listbox-oninput-fired-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/select/listbox-oninput-fired.html [new file with mode: 0644]
LayoutTests/fast/forms/select/menulist-oninput-fired-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/select/menulist-oninput-fired.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLSelectElement.cpp

index 6b1efcf..49b732d 100644 (file)
@@ -1,3 +1,18 @@
+2014-03-20  Lorenzo Tilve  <ltilve@igalia.com>
+
+        "input" event is not fired when changing a select element's value
+        https://bugs.webkit.org/show_bug.cgi?id=117526
+
+        Reviewed by Antti Koivisto.
+
+        Add tests to verify that input event is dispatched when listbox
+        or menulist values are modified.
+
+        * fast/forms/select/listbox-oninput-fired-expected.txt: Added.
+        * fast/forms/select/listbox-oninput-fired.html: Added.
+        * fast/forms/select/menulist-oninput-fired-expected.txt: Added.
+        * fast/forms/select/menulist-oninput-fired.html: Added.
+
 2014-03-20  Radu Stavila  <stavila@adobe.com>
 
         [CSS Regions] The height of a scrollable element flowed inside a scrollable region is not computed correctly
diff --git a/LayoutTests/fast/forms/select/listbox-oninput-fired-expected.txt b/LayoutTests/fast/forms/select/listbox-oninput-fired-expected.txt
new file mode 100644 (file)
index 0000000..3dbd647
--- /dev/null
@@ -0,0 +1,21 @@
+Selecting listbox options should fire input event
+
+
+Pressing down arrow key
+PASS
+Pressing down arrow key
+PASS
+Pressing up arrow key
+PASS
+Pressing page down key
+PASS
+Pressing page up key
+PASS
+Pressing end key
+PASS
+Pressing home key
+PASS
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/select/listbox-oninput-fired.html b/LayoutTests/fast/forms/select/listbox-oninput-fired.html
new file mode 100644 (file)
index 0000000..3d4034f
--- /dev/null
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../../../resources/js-test.js"></script>
+<script>
+window.jsTestIsAsync = true;
+
+var finishTest = false;
+
+function selectInputDispatched() {
+    debug("PASS");
+    if (finishTest)
+        finishJSTest();
+}
+
+function test() {
+    document.getElementById("bug-test").focus();
+    if (window.eventSender) {
+        debug("Pressing down arrow key");
+        eventSender.keyDown('downArrow');
+
+        debug("Pressing down arrow key");
+        eventSender.keyDown('downArrow');
+
+        debug("Pressing up arrow key");
+        eventSender.keyDown('upArrow');
+
+        debug("Pressing page down key");
+        eventSender.keyDown('pageDown');
+
+        debug("Pressing page up key");
+        eventSender.keyDown('pageUp');
+
+        debug("Pressing end key");
+        eventSender.keyDown('end');
+
+        finishTest = true;
+
+        debug("Pressing home key");
+        eventSender.keyDown('home');
+    } else {
+        debug("Test manually by pressing up/down key. Should get PASS message");
+        finishJSTest();
+    }
+}
+
+successfullyParsed = true;
+</script>
+</head>
+<body onload="test()">
+<p>Selecting listbox options should fire input event</p>
+
+<select id="bug-test" onInput="selectInputDispatched()" multiple="multiple">
+  <option>option 1</option>
+  <option>option 2</option>
+  <option>option 3</option>
+  <option>option 4</option>
+</select>
+
+<div id="console"></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/select/menulist-oninput-fired-expected.txt b/LayoutTests/fast/forms/select/menulist-oninput-fired-expected.txt
new file mode 100644 (file)
index 0000000..71f71cf
--- /dev/null
@@ -0,0 +1,9 @@
+Selecting menu list options should fire input event
+
+
+Pressing 2 key
+PASS
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/select/menulist-oninput-fired.html b/LayoutTests/fast/forms/select/menulist-oninput-fired.html
new file mode 100644 (file)
index 0000000..c9c5b90
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../../../resources/js-test.js"></script>
+</head>
+<body>
+<p>Selecting menu list options should fire input event</p>
+
+<select id="bug-test" onInput="debug('PASS')">
+  <option>1</option>
+  <option>2</option>
+  <option>3</option>
+  <option>4</option>
+  <option>5</option>
+</select>
+<div id="console"></div>
+<script>
+    document.getElementById("bug-test").focus();
+    if (window.eventSender) {
+
+        debug("Pressing 2 key");
+        eventSender.keyDown('2');
+    } else {
+        debug("Test manually by pressing option key. Should get PASS message");
+    }
+</script>
+</body>
+</html>
index 2eec9f1..9878608 100644 (file)
@@ -1,3 +1,26 @@
+2014-03-20  Lorenzo Tilve  <ltilve@igalia.com>
+
+        "input" event is not fired when changing a select element's value
+        https://bugs.webkit.org/show_bug.cgi?id=117526
+
+        Reviewed by Antti Koivisto.
+
+        Add a call to dispatch input event when listbox or menulist
+        values are modified.
+
+        According to the spec: "When the user agent is to send select update
+        notifications, queue a task to first fire a simple even that bubbles
+        named input at the select element, and then fire a simple event that
+        bubbles named change at the select element, using the user interaction
+        task source as the task source."
+
+        Tests: fast/forms/select/listbox-oninput-fired.html
+               fast/forms/select/menulist-oninput-fired.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::listBoxOnChange):
+        (WebCore::HTMLSelectElement::dispatchChangeEventForMenuList):
+
 2014-03-20  Radu Stavila  <stavila@adobe.com>
 
         [CSS Regions] The height of a scrollable element flowed inside a scrollable region is not computed correctly
index a50605e..a4de316 100644 (file)
@@ -682,8 +682,10 @@ void HTMLSelectElement::listBoxOnChange()
         m_lastOnChangeSelection[i] = selected;
     }
 
-    if (fireOnChange)
+    if (fireOnChange) {
+        dispatchInputEvent();
         dispatchFormControlChangeEvent();
+    }
 }
 
 void HTMLSelectElement::dispatchChangeEventForMenuList()
@@ -694,6 +696,7 @@ void HTMLSelectElement::dispatchChangeEventForMenuList()
     if (m_lastOnChangeIndex != selected && m_isProcessingUserDrivenChange) {
         m_lastOnChangeIndex = selected;
         m_isProcessingUserDrivenChange = false;
+        dispatchInputEvent();
         dispatchFormControlChangeEvent();
     }
 }