Bug 145869 - Select validation does not correctly work when handling change event
Summary: Select validation does not correctly work when handling change event
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-10 20:11 PDT by mh35jp
Modified: 2015-08-19 17:43 PDT (History)
2 users (show)

See Also:


Attachments
Test case (594 bytes, text/html)
2015-06-10 20:11 PDT, mh35jp
no flags Details
Patch (4.83 KB, patch)
2015-08-19 17:35 PDT, Wenson Hsieh
dino: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mh35jp 2015-06-10 20:11:40 PDT
Created attachment 254703 [details]
Test case

Expected behavior
Select a value->1 ... Should be changed to true, but remains false
1->Select a value ... Should be changed to false, but true
Comment 1 Wenson Hsieh 2015-08-19 17:35:32 PDT
Created attachment 259434 [details]
Patch
Comment 2 Dean Jackson 2015-08-19 17:39:52 PDT
Comment on attachment 259434 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259434&action=review

> Source/WebCore/ChangeLog:14
> +        Test: fast/forms/onchange-select-check-validity.html
> +
> +        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.

Normally the Test line comes last.

> LayoutTests/fast/forms/onchange-select-check-validity.html:17
> +        select.onchange = showFormValidity;
> +        select.addEventListener("change", showFormValidity);

I think these two lines do the same thing. You only need one of them.
Comment 3 Wenson Hsieh 2015-08-19 17:43:07 PDT
Comment on attachment 259434 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=259434&action=review

>> Source/WebCore/ChangeLog:14
>> +        this issue.
> 
> Normally the Test line comes last.

got it.

>> LayoutTests/fast/forms/onchange-select-check-validity.html:17
>> +        select.addEventListener("change", showFormValidity);
> 
> I think these two lines do the same thing. You only need one of them.

good catch. fixed!