New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 792336 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Dec 13
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac , Fuchsia
Pri: 2
Type: Bug



Sign in to add a comment

change event is dispatched when .files property is set at <input type="file"> element

Reported by guest271...@gmail.com, Dec 6 2017

Issue description

UserAgent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/62.0.3202.94 Chrome/62.0.3202.94 Safari/537.36

Steps to reproduce the problem:
1. Progammatically set .files property of <input type="file"> element to a FileList object
2. 
3. 

What is the expected behavior?
change event should not be dispatched to the element

What went wrong?
change event is dispatched to the element

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 62.0.3202.94  Channel: stable
OS Version: 
Flash Version: 

See https://github.com/whatwg/html/issues/3269
 
setFileList.js
1.9 KB View Download
Cc: bsittler@chromium.org jsb...@chromium.org pwnall@chromium.org
Labels: Triaged-ET Needs-Feedback Needs-Triage-M62
"Thanks for filing the issue!

@Reporter: Could you please provide a sample test file/URL to check the issue from TE end. Any further inputs from your end helps us to triage the issue in a better way."
Components: -Blink>FileAPI Blink>Forms>File
Labels: -Needs-Feedback
Status: Available (was: Unconfirmed)
Here's a more minimal repro:

(1) go to about:blank
(2) run this on the console:

input = Object.assign(document.createElement('input'), {type: 'file'}); input.onchange = e => alert('change'); dt = new DataTransfer; dt.items.add(new File([], '')); input.files = dt.files

Expect: no alert
Actual: alert

Cc: keishi@chromium.org
A fix is simple - make SetFiles() delegate to a new SetFilesInternal(..., bool send_event_if_changed) or some such - but we need to understand the history of the current behavior.

Project Member

Comment 6 by sheriffbot@chromium.org, Dec 10

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: -Hotlist-Recharge-Cold Hotlist-GoodFirstBug OS-Android OS-Chrome OS-Fuchsia OS-Mac OS-Windows
Status: Available (was: Untriaged)
IMO, this is an accidental behavior.  We should fix.

Owner: jsb...@chromium.org
Status: Started (was: Available)
Project Member

Comment 9 by bugdroid1@chromium.org, Dec 13

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/316b593b45afa16f32bb72acb177700e9be2ee44

commit 316b593b45afa16f32bb72acb177700e9be2ee44
Author: Joshua Bell <jsbell@chromium.org>
Date: Thu Dec 13 19:34:23 2018

File Inputs: Don't generate change events when 'files' is set

The <input type=file> element generates "change" events when the user
interacts with the control to select files, exposed as the 'files'
property (a FileList). This property can be assigned to by script, and
should not generate a "change" event in such a case. It was
erroneously doing so, so fix it.

Bug:  792336 
Change-Id: Iaa4297332e9c048daf7142aef3797fb59b0d5bcf
Reviewed-on: https://chromium-review.googlesource.com/c/1374791
Commit-Queue: Joshua Bell <jsbell@chromium.org>
Reviewed-by: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616394}
[modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/file_input_type.cc
[modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/file_input_type.h
[modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/input_type.cc
[modify] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/renderer/core/html/forms/input_type.h
[add] https://crrev.com/316b593b45afa16f32bb72acb177700e9be2ee44/third_party/blink/web_tests/fast/files/file-list-change-events.html

Status: Fixed (was: Started)

Sign in to add a comment