-
Notifications
You must be signed in to change notification settings - Fork 37
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
Interoperability issue: navigator.clipboard.write()
and navigator.clipboard.writeText()
user gesture requirement
#182
Comments
@tomayac Is this on the latest 104 stable build? I added the transient user activation requirement for |
I tested on |
This comment was marked as off-topic.
This comment was marked as off-topic.
Version 105.0.5195.54 (Official Build) (64-bit) |
Tested on Version 1.42.97 Chromium: 104.0.5112.102 (Official Build) (64-bit) - silent fail - no error, but no effect on clipboard as well |
It should be noted that Chromium-based browsers do have some restrictions for writing text to the clipboard:
(https://groups.google.com/a/chromium.org/g/blink-dev/c/epeaao7l13M/m/b8ewAH5uBwAJ) So if a web page is loaded into a background tab, it won’t be able to write to the clipboard. |
Some developments in the Brave browser: brave/brave-core#14901 |
As of this commit, Chromium requires either user activation (at the time of the write) or an explicit permission grant (which is durable across many reads/writes) for writing to the clipboard. As noted in the spec, there are known use cases which rely on the permission grant flow as opposed to the user gesture. |
@evanstade your link is missing the protocol (https) |
(Corrected link for #182 (comment): https://crrev.com/10300ac7da93a7e322274f1e.) Are people fine with me closing the Issue as completed? |
Perhaps I am stupid. Is this related to cve-2022-3075. If so I was under the impression this was patched. if I go to webplatfoem.news it continues to write to my clipboard. My chrome is: 106.0.5249.119, My Vivaldi is 5.5.2805.38, and Opera |
@simevidas
|
Attempting to write to the clipboard should only trigger a prompt if there's no user action attached. Yes, Chromium reuses the same permission for both gesture-less reads and writes. The text was not updated because reading is considered more powerful than writing. |
Telling not the truth in such dialogs is IMO a very bad move. |
It is the truth in that the same underlying permission is used for both actions. Granting this permission will affect reading. To avoid permission fatigue, we try to avoid creating too many distinct permissions. |
This issue is creating unnecessary noise in the clipboard repo. The original issue has already been addressed, so if there are any concerns/bugs, please open bugs in the chromium bug database. I'm going to close this issue. |
It also disables one test that writes in the clipboard due lack of support in the clipboard api refs cypress-io/cypress#2752 w3c/clipboard-apis#182 w3c/clipboard-apis#52
(This was brought up in the context of @simevidas' tweet.)
When attempting to write to the clipboard via either of
navigator.clipboard.write()
ornavigator.clipboard.writeText()
, both Safari 🚫 and Firefox 🚫 require a user gesture:In contrast, and this is the interoperability issue I guess, Chrome ✅ happily proceeds. Brave, based on Chromium, considered disabling this behavior (brave/brave-browser#16890).
One use case requiring a user gesture would break is that of remote clipboard synchronization, which is explicitly mentioned in the spec. Maybe Capability Delegation could be the answer here?!
Here's a test page for
write()
courtesy of Šime, and here's a test page forwriteText()
(based on Šime's).The text was updated successfully, but these errors were encountered: