Bug 145869

Summary: Select validation does not correctly work when handling change event
Product: WebKit Reporter: mh35jp
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ahmad.saleem792, simon.fraser, wenson_hsieh
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Test case
none
Patch dino: review+

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!
Comment 4 Ahmad Saleem 2022-10-25 13:34:35 PDT
Landed and didn't backed out - https://github.com/WebKit/WebKit/commit/dfc4f77e61d39a165b4d9c8edd877282bde90e84

Marking this as "RESOLVED FIXED".