Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Re-allow clipboard copy on non-https sites #17118
Re-allow clipboard copy on non-https sites #17118
Changes from 4 commits
8c0ae0c
a0b3837
5b127b1
01b36b4
e001004
ca20ae2
e36864a
fe2b719
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't
navigator.clipboard.writeText
throw an error in case thisclipboard-write
permission is being denied? It would be better to catch and handle such a error if it exists.I think I recall copy works on non-secure origin
http://localhost
, so I thinkisSecureContext
is not the only condition that a browser checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks the "clipboard-write" and "clipboard-read" permissions, however,
navigator.permissions.query({name:"clipboard-write"})
isn't fully supported on all browsers yet.On both firefox and chrome, the
navigator.clipboard
object only exists if the "clipboard-write" permission is granted.It's just that on https sites, the clipboard permission is granted (for desktop at least) by default.
Also,
window.isSecureContext
is true on localhost.The easiest way to resolve this confusion is to move the
fallbackCopyToClipboard
into thecatch { }
, as then any error would attempt the fallback.(so I'll do that for next commit)