Closed
Bug 1206616
Opened 9 years ago
Closed 9 years ago
<input> of type=checkbox,radio, file doesn't fire `input` events
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: mozilla, Assigned: jessica)
References
()
Details
(Keywords: html5, testcase, Whiteboard: [tw-dom] btpp-active)
Attachments
(2 files, 2 obsolete files)
7.46 KB,
patch
|
jessica
:
review+
|
Details | Diff | Splinter Review |
5.01 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
Per the following portions of the HTML specification:
* https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox):event-input-input
* https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):event-input-input
* https://html.spec.whatwg.org/multipage/forms.html#file-upload-state-(type=file):event-input-input
when the user changes the checkedness of an <input type="checkbox"> or <input type="radio">, or when a user changes the selected files of an <input type="file">, the browser is supposed to fire an `input` event (https://developer.mozilla.org/en-US/docs/Web/Events/input ) at that <input> element.
Firefox 42 doesn't comply with this, and doesn't fire `input` events in these cases.
Testcase: http://output.jsbin.com/jojoji
Comment 1•9 years ago
|
||
Confirmed also in Firefox 41
Component: Untriaged → DOM: Events
Product: Firefox → Core
Version: Trunk → 41 Branch
Reporter | ||
Updated•9 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Reporter | ||
Updated•9 years ago
|
Reporter | ||
Updated•9 years ago
|
See Also: → https://bugs.webkit.org/show_bug.cgi?id=149398
Reporter | ||
Updated•9 years ago
|
See Also: → https://github.com/whatwg/html/issues/601
Updated•9 years ago
|
Whiteboard: [tw-dom]
Assignee | ||
Comment 3•9 years ago
|
||
Per [1], checkbox, radio and file input types have a defined activation behaviour. In the defined activation behaviour described in each of their section, 'input' event is fired before 'change' event, so I'm going to add firing 'input' events before 'change' events.
[1] https://html.spec.whatwg.org/multipage/forms.html#common-input-element-events
Updated•9 years ago
|
Whiteboard: [tw-dom] → [tw-dom] btpp-active
Assignee | ||
Comment 4•9 years ago
|
||
Olli, may I have your feedback on this? Thanks.
Attachment #8743158 -
Flags: feedback?(bugs)
Comment 5•9 years ago
|
||
Comment on attachment 8743158 [details] [diff] [review]
patch, v1.
So
https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-(type=checkbox)
https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio)
https://html.spec.whatwg.org/multipage/forms.html#file-upload-state-(type=file)
Don't we dispatch the "change" for checkbox and radiobutton
http://mxr.mozilla.org/mozilla-central/source/dom/html/HTMLInputElement.cpp#3852
Dispatching "input" in the same place would be good.
And the spec talks about activation behavior, which in Gecko terminology is pretty much PostHandleEvent.
Also, dispatching the event in SetCheckedInternal may cause us to dispatch the event twice if 'click' which is changing the state is cancelled (.preventDefault()), at least if I read the code right.
You could add a test for checkbox and radiobutton that (1) when doing click(), the click event is handled before
"change" and "input" and (2) that if click event is cancelled, neither of the events is dispatched.
Attachment #8743158 -
Flags: feedback?(bugs) → feedback+
Assignee | ||
Comment 6•9 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #5)
> Comment on attachment 8743158 [details] [diff] [review]
> patch, v1.
>
> So
> https://html.spec.whatwg.org/multipage/forms.html#checkbox-state-
> (type=checkbox)
> https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-
> (type=radio)
> https://html.spec.whatwg.org/multipage/forms.html#file-upload-state-
> (type=file)
>
>
> Don't we dispatch the "change" for checkbox and radiobutton
> http://mxr.mozilla.org/mozilla-central/source/dom/html/HTMLInputElement.
> cpp#3852
> Dispatching "input" in the same place would be good.
> And the spec talks about activation behavior, which in Gecko terminology is
> pretty much PostHandleEvent.
Thanks, that's a useful note.
>
> Also, dispatching the event in SetCheckedInternal may cause us to dispatch
> the event twice if 'click' which is changing the state is cancelled
> (.preventDefault()), at least if I read the code right.
Yes, you are right, the events were dispatched twice.
>
> You could add a test for checkbox and radiobutton that (1) when doing
> click(), the click event is handled before
> "change" and "input" and (2) that if click event is cancelled, neither of
> the events is dispatched.
I have added a test case for (2), do you think it covers (1) as well? (I'll upload my updated patch right away).
Assignee | ||
Comment 7•9 years ago
|
||
Attachment #8743158 -
Attachment is obsolete: true
Attachment #8743646 -
Flags: review?(bugs)
Comment 8•9 years ago
|
||
Comment on attachment 8743646 [details] [diff] [review]
patch, v2.
Is there really no web platform tests for this stuff. If so, surprising.
Attachment #8743646 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 9•9 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #8)
> Comment on attachment 8743646 [details] [diff] [review]
> patch, v2.
>
> Is there really no web platform tests for this stuff. If so, surprising.
Oh, actually there is. They are under testing/web-platform/tests/html/semantics/forms/the-input-element/ and are expected to fail right now.
But after running with the proposed patch, I still get an error:
"assert_false: click()-initiated input event shouldn't be trusted expected false got true"
But per spec, a simple event is trusted [1], unless I am missing something here.
[1] https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-simple-event
Assignee | ||
Comment 10•9 years ago
|
||
Revised commit message.
Attachment #8743646 -
Attachment is obsolete: true
Attachment #8745169 -
Flags: review+
Assignee | ||
Comment 11•9 years ago
|
||
Updated wpt based on spec: events should be trusted.
Attachment #8745170 -
Flags: review?(bugs)
Comment 12•9 years ago
|
||
FYI, I filed https://github.com/whatwg/html/issues/1126
Comment 13•9 years ago
|
||
Comment on attachment 8745170 [details] [diff] [review]
Part 2: update web platform tests. r=smaug
Thanks.
If the specification bug is fixed, checkbox.html and radio.html may be changed back to the old behavior, but that is something for a different bug.
Attachment #8745170 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 14•9 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #13)
> Comment on attachment 8745170 [details] [diff] [review]
> Part 2: update web platform tests. r=smaug
>
> Thanks.
> If the specification bug is fixed, checkbox.html and radio.html may be
> changed back to the old behavior, but that is something for a different bug.
Got it. Thanks for filing the bug.
Assignee | ||
Comment 15•9 years ago
|
||
Comment 17•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/ddb96fbc66c9
https://hg.mozilla.org/integration/mozilla-inbound/rev/477b790ce198
Keywords: checkin-needed
Comment 18•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/ddb96fbc66c9
https://hg.mozilla.org/mozilla-central/rev/477b790ce198
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Comment 19•7 years ago
|
||
Is this really fixed?
Please see this test page, there is one failing test:
http://w3c-test.org/html/semantics/forms/the-input-element/checkbox-click-events.html
Comment 20•7 years ago
|
||
That failing test doesn't seem to have anything to do with input events.
But feel free to file a new bug about the failure.
Comment 21•7 years ago
|
||
Alright, I opened bug 1434268
You need to log in
before you can comment on or make changes to this bug.
Description
•