Skip to content

Bug-1773681 Showing Paste button for navigator.clipboard.readText()#42263

Merged
Rob--W merged 11 commits intomdn:mainfrom
rebloor:Bug-1773681-Showing-Paste-button-for-navigator.clipboard.readText()
Jan 27, 2026
Merged

Bug-1773681 Showing Paste button for navigator.clipboard.readText()#42263
Rob--W merged 11 commits intomdn:mainfrom
rebloor:Bug-1773681-Showing-Paste-button-for-navigator.clipboard.readText()

Conversation

@rebloor
Copy link
Contributor

@rebloor rebloor commented Dec 5, 2025

Description

This change addresses the dev-docs-needed requirement of Bug 1773681 Enable showing "Paste" button for navigator.clipboard.readText() when called from Addons which don't have clipboardRead permssion.

The changes include:

  • a release note.
  • an update to the Interact with the clipboard article. In addition to aligning the documentation with this change, references to the deprecated document.execCommand methods were removed.
  • an update to the clipboard section on the Pesmissions page to remove references to the deprecated document.execCommand methods.
  • an update to the Clipboard API overview page's Security consideration section to align the documentation with this change.

Related issues and pull requests

Notes in the BCD updated in mdn/browser-compat-data#28587.
Also fixes #42688.

@rebloor rebloor requested review from Rob--W and dotproto December 5, 2025 18:04
@rebloor rebloor self-assigned this Dec 5, 2025
@rebloor rebloor requested review from a team as code owners December 5, 2025 18:04
@rebloor rebloor added the Content:WebExt WebExtensions docs label Dec 5, 2025
@rebloor rebloor requested review from pepelsbey and sideshowbarker and removed request for a team December 5, 2025 18:04
@github-actions github-actions bot added Content:WebAPI Web API docs Content:Firefox Content in the Mozilla/Firefox subtree size/m [PR only] 51-500 LoC changed labels Dec 5, 2025
@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Dec 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Dec 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2025

Preview URLs (4 pages)

Flaws (1)

Note! 3 documents with no flaws that don't need to be listed. 🎉

Found an unexpected or unresolvable flaw? Please report it here.

URL: /en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard
Title: Interact with the clipboard
Flaw count: 1

  • broken_links:
    • Link /en-US/docs/Web/Security/Secure_Contexts is a redirect
External URLs (1)

URL: /en-US/docs/Mozilla/Firefox/Releases/147
Title: Firefox 147 release notes for developers (Stable)

(comment last updated: 2026-01-27 13:03:35)

@sideshowbarker sideshowbarker removed their request for review December 8, 2025 03:52
Copy link
Contributor

@dotproto dotproto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that this change does not accurately reflect how to work with the clipboard in extensions across browsers. Specifically, Chrome does not expose navigator.clipboard to extension service workers and offscreen documents cannot access navigator.clipboard due to the API's document focus requirements. As a result, Chrome extensions have to fall back to using the deprecated document.execCommand() APIs in an offscreen document or using navigator.clipboad in a different context (content scripts or extension pages).

While I strongly feel that we should target cross-browser extension develpment, I don't want to block this PR or require a rewrite at the moment. That said, if we don't integrate cross-browser develpment in this revision, we may need to revise this article again in the coming months. @rebloor, do you have any preferences on how we should proceed?

@dotproto dotproto self-requested a review December 8, 2025 19:59
…d.readText()' of ssh://github.com/rebloor/content into Bug-1773681-Showing-Paste-button-for-navigator.clipboard.readText()
@rebloor
Copy link
Contributor Author

rebloor commented Dec 11, 2025

@dotproto I've added the additional Chrome information. I'd checked for any additional information prior to making the changes and couldn't find anything suggesting there were any further considerations. Do you have a link to any Chrome documentation?

Copy link
Member

@Rob--W Rob--W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the feedback below, also some browser compatibility notes:

  • clipboardWrite permission enables writing to the clipboard from all extension contexts and content scripts in Firefox (and Chrome). In Chrome and Safari, the clipboardWrite permission is only supported in extension contexts (not content scripts).
  • clipboardRead permission enables writing to the clipboard from all extension contexts and content scripts in Firefox and Chrome. In Chrome, the clipboardRead permission is only supported in extension contexts (not content scripts). Safari does not support the clipboardRead permission at all.

EDIT: Chrome also supports reading and writing from clipboard in content scripts. When I tested it before, I made a mistake.


> [!NOTE]
> The `clipboard-write` permission name is not supported in Firefox, only Chromium browsers.
The Clipboard API write methods {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} and {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}} write arbitrary content to the clipboard. The methods are available from a secure context after the extension's user has performed {{Glossary("Transient Activation","transient activation")}}. However, with the [`"clipboardWrite"` permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite) the methods are available without transient activation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • readText -> write.
  • available -> rephrased, because "methods are available" could imply that the API method is missing if the conditions have not been met. However, the methods are always there, they just reject if the requirements have not been met.
Suggested change
The Clipboard API write methods {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} and {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}} write arbitrary content to the clipboard. The methods are available from a secure context after the extension's user has performed {{Glossary("Transient Activation","transient activation")}}. However, with the [`"clipboardWrite"` permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite) the methods are available without transient activation.
The Clipboard API methods {{domxref("Clipboard.write", "navigator.clipboard.write()")}} and {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}} write arbitrary content to the clipboard. The methods are available from a secure context, but are only functional after the extension's user has performed {{Glossary("Transient Activation","transient activation")}}. However, with the [`"clipboardWrite"` permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite) transient activation is not required.

Please apply a similar edit to the other section.

}
```

### Using execCommand()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you restore the full examples here? They are more helpful than the replacements that you added. The original explanation is more tutorial-like and a walkthrough with all relevant details (including a highlight of the difference of running with and without user interaction).

And although execCommand has been deprecated, I do not see it going away realistically, due to its long history, prevalent use, and supporting capabilities that are not available in the clipboard API.

For that reason, instead of rewriting the example, I'd suggest to restore the execCommand examples.


## Changes for add-on developers

- When using [navigator.clipboard.readText()](/en-US/docs/Web/API/Clipboard/readText) or [navigator.clipboard.read()](/en-US/docs/Web/API/Clipboard/read) without the `clipboardRead` permission, a clipboard paste button is displayed to obtain user confirmation. If the extension has `clipboardRead` permission, it reads the clipboard data without user confirmation. For more information on working with the clipboard in extensions, see [Interact with the clipboard](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard). ([Firefox bug 1773681](https://bugzil.la/1773681))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- When using [navigator.clipboard.readText()](/en-US/docs/Web/API/Clipboard/readText) or [navigator.clipboard.read()](/en-US/docs/Web/API/Clipboard/read) without the `clipboardRead` permission, a clipboard paste button is displayed to obtain user confirmation. If the extension has `clipboardRead` permission, it reads the clipboard data without user confirmation. For more information on working with the clipboard in extensions, see [Interact with the clipboard](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard). ([Firefox bug 1773681](https://bugzil.la/1773681))
- When using [navigator.clipboard.readText()](/en-US/docs/Web/API/Clipboard/readText) or [navigator.clipboard.read()](/en-US/docs/Web/API/Clipboard/read) without the `clipboardRead` permission, a clipboard paste button is displayed to obtain user confirmation. If the extension has `clipboardRead` permission, it continues to read the clipboard data without user confirmation, as before. For more information on working with the clipboard in extensions, see [Interact with the clipboard](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard). ([Firefox bug 1773681](https://bugzil.la/1773681))

@rebloor rebloor closed this Dec 31, 2025
@rebloor rebloor deleted the Bug-1773681-Showing-Paste-button-for-navigator.clipboard.readText() branch December 31, 2025 17:45
@rebloor rebloor restored the Bug-1773681-Showing-Paste-button-for-navigator.clipboard.readText() branch December 31, 2025 17:47
@rebloor rebloor reopened this Dec 31, 2025
…ance and add additional compatibility details.
@rebloor rebloor requested a review from Rob--W January 1, 2026 17:45
Two permissions enable an extension to interact with the clipboard:

- `clipboardWrite`
- : Write to the clipboard using {{DOMxRef("Clipboard.write()")}}, {{DOMxRef("Clipboard.writeText()")}}, `document.execCommand("copy")` or `document.execCommand("cut")`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep mention of execCommand. The permissions still unlock functionality on these APIs.

@github-actions github-actions bot added the merge conflicts 🚧 [PR only] label Jan 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Jan 2, 2026
@Rob--W
Copy link
Member

Rob--W commented Jan 21, 2026

@rebloor Please see my latest comments (and also the ones from the round before that).

Also note that I corrected a mistake from before, I previously stated that Chrome does not support clipboardWrite/clipboardRead in content scripts. That was an error on my part, I have edited my previous comment (#42263 (review)) and added suggested edits to correct the pending changes in the docs.

Co-authored-by: Rob Wu <rob@robwu.nl>
rebloor and others added 2 commits January 22, 2026 04:44
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@rebloor
Copy link
Contributor Author

rebloor commented Jan 21, 2026

@Rob--W apologies for missing some of your earlier comments. I believe everything should be addressed now.

@rebloor rebloor requested a review from Rob--W January 21, 2026 16:07
- The `clipboard-read` and `clipboard-write` permissions are not supported (and not planned to be supported) by Firefox or Safari.

Firefox [Web Extensions](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard):
Firefox [web extensions](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is WebExtensions, with those capitals and no spaces.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say it's “Web Extensions” when we're talking about API or the spec, but just “web extensions” when we're casually talking about extensions.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(no changes necessary, just sharing some thoughts)

I would say it's “Web Extensions” when we're talking about API or the spec, but just “web extensions” when we're casually talking about extensions.

Indeed. The intended guidelines are at https://wiki.mozilla.org/Add-ons/Terminology

Except for extensions, "browser extension" or simply just "extension" is the generic term. But I have seen all terms with different spacing and capitalizations used interchangeably, so unless there is a concentrated effort to review and update all mentions, I expect the flip flopping to continue.

The current phrase here is "Firefox web extension". While the target article contains Firefox specific information, it also describes Chrome's and Safari's behavior, all within the realm of browser extensions.

Copy link
Member

@Rob--W Rob--W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get this merged quickly so that other docs (#42747) can be worked on.

@Rob--W Rob--W merged commit bdb21cd into mdn:main Jan 27, 2026
8 checks passed
@rebloor rebloor deleted the Bug-1773681-Showing-Paste-button-for-navigator.clipboard.readText() branch January 27, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:Firefox Content in the Mozilla/Firefox subtree Content:WebAPI Web API docs Content:WebExt WebExtensions docs size/m [PR only] 51-500 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect navigator.clipboard.write support statement on interact with clipboard page

4 participants