Disabled select element should not fire onchange event. When dragging a disabled select element it would fire an onchange event, because there was no cached selected item. Added a check before firing the event to prevent it if the element is disabled.


Review URL: https://chromiumcodereview.appspot.com/14931006

git-svn-id: svn://svn.chromium.org/blink/trunk@149781 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/fast/forms/select/listbox-disabled-scroll-no-onchange-expected.txt b/LayoutTests/fast/forms/select/listbox-disabled-scroll-no-onchange-expected.txt
new file mode 100644
index 0000000..da716ad
--- /dev/null
+++ b/LayoutTests/fast/forms/select/listbox-disabled-scroll-no-onchange-expected.txt
@@ -0,0 +1,11 @@
+Test that scrolling the listbox does not fire onchange event
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+Success if onchange was not fired.
+PASS successfullyParsed is true
diff --git a/LayoutTests/fast/forms/select/listbox-disabled-scroll-no-onchange.html b/LayoutTests/fast/forms/select/listbox-disabled-scroll-no-onchange.html
new file mode 100644
index 0000000..802cd98
--- /dev/null
+++ b/LayoutTests/fast/forms/select/listbox-disabled-scroll-no-onchange.html
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
+<p id="description"></p>
+<select id="test" disabled size=3">
+<option selected>foo1</option>
+<div id="result">Success if onchange was not fired.</div>
+<div id="console"></div>
+description('Test that scrolling the listbox does not fire onchange event');
+function handleChange() {
+    $('result').textContent = 'Failed. A disabled select should not fire onchange event.';
+$('test').addEventListener('change', handleChange);
+if (!window.eventSender) {
+    debug('Click and drag the select element using the mouse. It should not fire onchange event.');
+} else {
+    mouseMoveToIndexInListbox(1, 'test');
+    eventSender.mouseDown(0);
+    mouseMoveToIndexInListbox(2, 'test');
+    eventSender.mouseUp(0);
+<script src="../../js/resources/js-test-post.js"></script>
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index 5767d02..fbcbd05 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -640,6 +640,8 @@
 void HTMLSelectElement::listBoxOnChange()
     ASSERT(!usesMenuList() || m_multiple);
+    if (isDisabledFormControl())
+        return;
     const Vector<HTMLElement*>& items = listItems();