Bug 180465 - change event is dispatched when .files property is set at <input type="file"> element
Summary: change event is dispatched when .files property is set at <input type="file">...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: BrowserCompat, InRadar
Depends on:
Blocks:
 
Reported: 2017-12-05 22:56 PST by guest271314
Modified: 2021-08-24 16:33 PDT (History)
15 users (show)

See Also:


Attachments
change event dispatched when .files set at <input type="file"> (1.86 KB, application/javascript)
2017-12-05 22:56 PST, guest271314
no flags Details
Patch (10.42 KB, patch)
2021-08-24 13:29 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description guest271314 2017-12-05 22:56:04 PST
Created attachment 328552 [details]
change event dispatched when .files set at <input type="file">

Programmatically set .files property of <input type="file"> element to a FileList object

Expected behaviour: change event should not be dispatched to the element
Actual result: change event is dispatched to the element

Browser: Chromium 62

See https://bugs.chromium.org/p/chromium/issues/detail?id=792336, https://github.com/whatwg/html/issues/3269
Comment 1 Simon Fraser (smfr) 2019-06-16 21:17:30 PDT
Does this reproduce in Safari? Chrome bugs should be filed in the Chromium bug tracker.
Comment 2 Kaiido 2021-08-04 18:34:48 PDT
This is a Safari only bug, still reproducible in current TP Release 128 (Safari 15.0, WebKit 16612.1.22.11.3)

Here is a fiddle reproducing the issue: https://jsfiddle.net/34sxmbqc/

Specs (https://html.spec.whatwg.org/multipage/input.html#dom-input-files) do not ask to fire an event here, since the change has been caused by script manipulation.

The particularly alarming point is that this event even has the `isTrusted` property set to `true`.
Comment 3 Chris Dumez 2021-08-24 13:29:14 PDT
Created attachment 436325 [details]
Patch
Comment 4 EWS 2021-08-24 16:32:05 PDT
Committed r281527 (240899@main): <https://commits.webkit.org/240899@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 436325 [details].
Comment 5 Radar WebKit Bug Importer 2021-08-24 16:33:27 PDT
<rdar://problem/82315840>