Select validation does not correctly work when handling change event
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Aug 2015 00:55:10 +0000 (00:55 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Aug 2015 00:55:10 +0000 (00:55 +0000)
commit6d50560a75ec29e3f8460b3ddb68ce741090c53d
tree3aa5ef6094a2f99fa8d9d4c74ead80548c0db680
parent9ef88aa1ffc388fb797450c7e593c1fbd0f064ee
Select validation does not correctly work when handling change event
https://bugs.webkit.org/show_bug.cgi?id=145869

Reviewed by Dean Jackson.

Source/WebCore:

When selecting an option in a <select> with validation that also has an onchange listener, calling
checkValidity() for the select within the onchange handler would produce incorrect results and (on
a debug build) crash at an assertion. This is because the change events were being dispatched before
form validity was updated. Making the validation step come before the change event dispatch fixes
this issue.

Test: fast/forms/onchange-select-check-validity.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::selectOption): Update validity before dispatching change events.

LayoutTests:

Tests that checkValidity() returns correct results from within the onchange handler of a
<select> when the validity of the selected option changes.

* fast/forms/onchange-select-check-validity-expected.txt: Added.
* fast/forms/onchange-select-check-validity.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/forms/onchange-select-check-validity-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/onchange-select-check-validity.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLSelectElement.cpp