[Webkit-unassigned] [Bug 222262] Javascript Clipboard API write() does not work after await
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Feb 23 08:18:24 PST 2021
https://bugs.webkit.org/show_bug.cgi?id=222262
--- Comment #3 from Wenson Hsieh <wenson_hsieh at apple.com> ---
> > You need to initiate the write inside click event handler as in:
> >
> > document.getElementById("copy-html").addEventListener("click", event => {
> > navigator.clipboard.write([
> > new ClipboardItem({
> > "text/png": async () => {
> > const response = await
> > fetch('https://upload.wikimedia.org/wikipedia/commons/4/47/
> > PNG_transparency_demonstration_1.png');
> > return await response.blob();
> > }
> > }),
> > ]);
> > });
>
>
> Hi Ryosuke,
>
> first of all, thanks for your reply. Unfortunately, I have tested your
> solution and I get the same error message.
Hi Felipe,
I adapted the above code as a test case here: https://whsieh.github.io/examples/dice, and it seems to work in Safari on macOS with a couple of adjustments:
- Changing the "text/png" above to "image/png".
- Making the corresponding value for the "image/png" type a Promise instead of an async function.
Please make sure that you're also testing in a secure context (https), where the clipboard API is available.
Thanks!
Wenson
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210223/c050ae96/attachment-0001.htm>
More information about the webkit-unassigned
mailing list