Open Bug 1792508 Opened 3 years ago Updated 1 year ago

Read clipboard get empty string when inside async function or callback after event loop

Categories

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

Firefox 106
defect

Tracking

()

UNCONFIRMED

People

(Reporter: linonetwo012, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0

Steps to reproduce:

https://stackblitz.com/edit/firefox-async-read-cllipboard-bug?file=index.ts

In WYSIWYG editor, we read clipboard using clipboardData?.getData('text') , and gets empty string. See link above for a reproduce.

We are optimizing performance by moving operations like reading clipboard to some async functions, and encountered this bug.

Actual results:

clipboardData?.getData('text') returns empty string

Expected results:

Should return acturial clipboard data like inside a sync function.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Editor' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Editor
Product: Firefox → Core
Component: DOM: Editor → DOM: Copy & Paste and Drag & Drop

Basically, we intentionally nuke the data from the DataTransfer when the event is done dispatching, so does Chrome.
For Promise.resolve case, we behave differently on resolving promise than Chrome regarding the microtask checkpoint, so it works on Chrome but not us.
For setTimeout case, both Chrome and us doesn't work.

Severity: -- → S3
See Also: → 1434915
You need to log in before you can comment on or make changes to this bug.