Skip to content

Commit

Permalink
Bug 1930748 [wpt PR 49127] - Update DataTransfer.Files upon change to…
Browse files Browse the repository at this point in the history
… it's items list, a=testonly

Automatic update from web-platform-tests
Update DataTransfer.Files upon change to it's items list

Refactored "blink::DataTransfer" class to update "files_" member when
it's DataObject's item list is changed, instead of doing the same in
the files getter.  This change ensures that files is updated
immediately when the DataTransfer's item list changes.

This fixes the issue where if a reference to DataTransfer.files is
stored in a separate JS variable, then any file items added to that
DataTransfer object are not reflected in the stored JS variable, until
the DataTransfer object's files getter is invoked. The issue is not
present in Safari and Firefox.

Bug: 342067834
Change-Id: Id59ca73ae0e8b744b247f1eabba9f70565245433
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5973363
Reviewed-by: Christine Hollingsworth <christinesm@chromium.org>
Commit-Queue: Rohan Raja <roraja@microsoft.com>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1382128}

--

wpt-commits: 60949643a99c4cfa5a6c2b43db9a6c418b9604a9
wpt-pr: 49127
  • Loading branch information
roraja authored and moz-wptsync-bot committed Nov 15, 2024
1 parent 80e6d9e commit b98982e
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Any JS reference DataTransfer.files should contain latest changes done to DataTransfer.items</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<input type=file multiple>
<script>
test(() => {
const dt = new DataTransfer();
const filelist = dt.files;
assert_equals(
filelist.length, 0,
'Initial filelist should be empty');
dt.items.add(new File([0], 'test'));
assert_equals(
filelist.length, 1,
'Filelist should reflect the changes done to items');
}, 'expect changed contents');
</script>

0 comments on commit b98982e

Please sign in to comment.