Closed Bug 1699743 Opened 3 years ago Closed 10 months ago

clipboardData.items does not support pasting files correctly

Categories

(Core :: DOM: Copy & Paste and Drag & Drop, enhancement, P2)

Firefox 85
enhancement

Tracking

()

RESOLVED FIXED
116 Branch
Tracking Status
relnote-firefox --- 116+
firefox116 --- fixed

People

(Reporter: govett, Assigned: evilpie)

References

(Blocks 2 open bugs)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15

Steps to reproduce:

  1. Copy a file from Finder/Windows explorer.
  2. Go to http://madebyevan.com/clipboard-test/
  3. Paste in the text field that says "Paste here"

Actual results:

You'll get two types: a text/plain item containing the file name, and an image/png item containing a file (no matter what file type you actually pasted). For actual PNG files, this file is readable, and for other file types (e.g. JPG) that can be converted to a PNG, this also works. However, for any other file type, DataTransferItem#getAsFile returns null. In addition, only a single file can be pasted, or no files will be available at all. This is tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=864052.

Expected results:

I would expect to only receive one item, representing the file that was pasted, in its original format rather than image/png. JPEGs or other images should not be converted, but be available in their original format, and other file types should also be supported rather than returning null from getAsFile.

This works as expected for drag and drop but not for pasting files, despite using the same DataTransfer API. I don't see why the privacy/security model would be different between them, if that's the reason. Note that Safari behaves as expected, but Chrome and Firefox currently match. See also https://bugs.chromium.org/p/chromium/issues/detail?id=316472.

I think this could also be considered an accessibility issue. Copy and paste is a keyboard friendly alternative to drag and drop, but currently it cannot be used due to this issue. This is currently affecting Adobe applications as we work to improve accessibility for drag and drop. We can add an explicit file upload button, but copy and paste is a much more efficient way to do this.

Ah actually, just found out that the Chrome team has been working on this and allows pasting arbitrary files in the current Canary release. See https://bugs.chromium.org/p/chromium/issues/detail?id=1175483.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Blocks: 1619251
Depends on: 1308007
Depends on: 1701319
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true

There are some potential privacy issues we should look out for (see discussion in https://github.com/mozilla/standards-positions/issues/484), but otherwise this seems fine.

Component: DOM: Core & HTML → DOM: Copy & Paste and Drag & Drop
Summary: clipboardData.items does not support files correctly → clipboardData.items does not support pasting files correctly

The severity field for this bug is relatively low, S3. However, the bug has 3 duplicates.
:hsinyi, could you consider increasing the bug severity?

For more information, please visit auto_nag documentation.

Flags: needinfo?(htsai)

Keep this as S3 for now; we will revisit or re-prioritize this along with other clipboard tasks.

Flags: needinfo?(htsai)
Depends on: 1762392
Depends on: 1781129
Depends on: 1778565
Duplicate of this bug: 1288773

dom.events.dataTransfer.mozFile.enabled in about:config can now be used to enable the pasting of files. I am going to use this bug to eventually enable this by default. For macOS support bug 1762392 needs to land.

Assignee: nobody → evilpies
Depends on: 1798548
Duplicate of this bug: 1801595
Depends on: 1810795
Duplicate of this bug: 1638318
Duplicate of this bug: 1829805
Severity: S3 → --
Type: defect → enhancement
Priority: -- → P2
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/202969c30f55
Enable file pasting by default. r=nika

Do you want to nominate this for 116 release notes?

Also wondering if we should enable this for early beta first? Unless of course there is a deadline or you feel the risk is low

Flags: needinfo?(evilpies)
Status: NEW → RESOLVED
Closed: 10 months ago
Resolution: --- → FIXED
Target Milestone: --- → 116 Branch

Do you want to nominate this for 116 release notes?

Yes, good idea.

Also wondering if we should enable this for early beta first? Unless of course there is a deadline or you feel the risk is low

There is no deadline. Sadly I don't think we are going to find any new issues on beta, in my experience the beta population doesn't help uncover clipboard bugs.

Flags: needinfo?(evilpies)

Release Note Request (optional, but appreciated)
[Why is this notable]: Feature supported by other browsers and better platform integration
[Affects Firefox for Android]: Not supported on Android
[Suggested wording]: It is now possible to copy any file from your operating system and paste it into Firefox.
[Links (documentation, blog post, etc)]:

relnote-firefox: --- → ?
QA Whiteboard: [qa-116b-p2]
Regressions: 1854747
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: