New issue
Advanced search Search tips

Issue 860562 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows , Chrome , Mac
Pri: 3
Type: Bug

Blocking:
issue 860563



Sign in to add a comment

Unable to attach a file to clipboardData in 'oncopy' event and unable to paste it back into same web app

Project Member Reported by paulkin...@google.com, Jul 5

Issue description

Chrome Version:69.0.3473.0 (Official Build) dev (64-bit)

What steps will reproduce the problem?
(1) https://drop-test.glitch.me/
(2) CTRL-C - will raise the oncopy event
(3) CTRL-V - will raise the onpaste event

What is the expected result?

I would expect the file to remain attached to the clipboardEvent.files object so
that I can use it again in my web app.

document.documentElement.addEventListener('copy', (event) => {
  const file = new File(['hello world'], 'testing.txt', {type: 'text/plain'});
  event.clipboardData.items.add(file);
  event.preventDefault();
});

document.documentElement.addEventListener('paste', (event) => {
  console.log(event.clipboardData.files.length); // == 0
  console.log(event.clipboardData.items.length); // == 1 .. the name of the file.
})

What happens instead?

clipboardData.files is empty, it should contain the file. The spec implies that this would be what is expected.

It's impossible to paste content that was generated by the origin back into the origin.
 
Summary: Unable to attach a file to clipboardData in 'oncopy' event and unable to paste it back into same web app (was: Unable to attach a file to clipboardData in 'oncopy' event and unable to paste it back into web app)
Blocking: 860563
Status: Available (was: Untriaged)
Our clipboard representation doesn't support arbitrary files. This needs to be fixed before Issue 860563 is tackled.

The clipboard representation is in https://cs.chromium.org/chromium/src/ui/base/clipboard/clipboard.h

Sign in to add a comment