Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manipulating ClipboardEvent.clipboardData #867

Open
ph-fritsche opened this issue Mar 1, 2022 · 1 comment
Open

Manipulating ClipboardEvent.clipboardData #867

ph-fritsche opened this issue Mar 1, 2022 · 1 comment
Labels
accuracy Improves the accuracy of how behavior is simulated

Comments

@ph-fritsche
Copy link
Member

  • @testing-library/user-event version: v14.0.0-beta.11

Relevant code or config

document.addEventListener('copy', e => e.clipboardData.setData('text', 'bar'))

document.addEventListener('cut', e => e.clipboardData.setData('text', 'bar'))

document.addEventListener('paste', e => e.clipboardData.setData('text', 'bar'))

Problem description:

When double-checking #862 and #866 , I discovered that accessing/manipulating ClipboardEvent.clipboardData is limited.

(In Firefox:)

The data written to Clipboard is independent from the clipboardData on the cut/copy event. Manipulating has no effect.
Also the handler cannot read the clipboard data.

The data pasted from Clipboard is readable on the paste event. But manipulating it results in a DOMException.

Suggested solution:

Check consistency across browsers. If it is, implement API accordingly.

@ph-fritsche ph-fritsche added the accuracy Improves the accuracy of how behavior is simulated label Mar 1, 2022
@SalahAdDin
Copy link

It would be nice to have a wait to mock the api, right now the permission checking does not work on it (i.e., navigator.permissions.query({name: "clipboard-read"})).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accuracy Improves the accuracy of how behavior is simulated
Projects
None yet
Development

No branches or pull requests

2 participants