Closed Bug 1688279 Opened 4 years ago Closed 4 years ago

Support strings as data in ClipboardItem

Categories

(Core :: DOM: Core & HTML, task, P2)

task

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: evilpie, Assigned: evilpie)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The initial implementation in Bug 1619947 only supports Blob. We want to supports strings as well. This reduces the required string copies when doing clipboard.writeText again.

I have a patch that seems to work well enough. There is one open question for me about doing copying images to the clipboard via strings. This seems to always fail. I suspect this is just not possible with UTF-8? We should probably just not allow this.

Testcase:

  let res = await fetch(`test.png`);
  var item = new ClipboardItem({
    'image/png': (await res.text())
  });
  await navigator.clipboard.write([item]);

Depends on D98085

Severity: -- → N/A
Priority: -- → P2
Blocks: 1688865
Pushed by evilpies@gmail.com: https://hg.mozilla.org/integration/autoland/rev/e3b6ea92e3ff Support strings as data in ClipboardItem r=nika
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27404 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: