diff --git a/files/en-us/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.md b/files/en-us/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.md
index 59781622fea3a9d..a7c6854d810b1db 100644
--- a/files/en-us/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.md
+++ b/files/en-us/mozilla/add-ons/webextensions/interact_with_the_clipboard/index.md
@@ -8,43 +8,25 @@ browser-compat:
sidebar: addonsidebar
---
-Working with the clipboard in extensions is transitioning from the Web API {{domxref("Document.execCommand()","document.execCommand")}} method (which is deprecated) to the {{domxref("Clipboard", "navigator.clipboard")}} method.
+You work with the clipboard in extensions using the Web API {{domxref("Clipboard", "navigator.clipboard")}} method and `"clipboardRead"` or `"clipboardWrite"` extension permissions. {{domxref("Clipboard", "navigator.clipboard")}} enables your extension to read and write arbitrary data from and to the clipboard.
> [!NOTE]
-> The {{domxref("Clipboard", "navigator.clipboard")}} API is a recent addition to the specification and may not be fully implemented in all browsers. This article describes some limitations, but be sure to review the compatibility tables for each method before using them to ensure that the API supports your needs.
+> The Web API {{domxref("Document.execCommand()","document.execCommand")}} method was used to provide clipboard functionality. However, {{domxref("Document.execCommand()","document.execCommand("copy")")}}, {{domxref("Document.execCommand()","document.execCommand("cut")")}}, and {{domxref("Document.execCommand()","document.execCommand("paste")")}} are deprecated and no longer guaranteed to work or be available on any browser. These features are documented in this article for historical reference.
-The difference between the two APIs is that {{domxref("Document.execCommand()","document.execCommand")}} this is analogous to the keyboard copy, cut, and paste actions – exchanging data between a webpage and clipboard – whereas {{domxref("Clipboard", "navigator.clipboard")}} writes and reads arbitrary data to and from the clipboard.
+The {{domxref("Clipboard", "navigator.clipboard")}} API provides methods for:
-{{domxref("Clipboard", "navigator.clipboard")}} provide separate methods to read or write:
+- Text content, using {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} and {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}}.
+- Images, rich text, HTML, and other rich content, using {{domxref("Clipboard.read", "navigator.clipboard.read()")}} and {{domxref("Clipboard.write", "navigator.clipboard.write()")}}.
-- text content, using {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} and {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}}.
-- images, rich text, HTML, and other rich content, using {{domxref("Clipboard.read", "navigator.clipboard.read()")}} and {{domxref("Clipboard.write", "navigator.clipboard.write()")}}.
-
-However, while {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} and {{domxref("Clipboard.writeText", "navigator.clipboard.writeText()")}} work on all browsers, {{domxref("Clipboard.read", "navigator.clipboard.read()")}} and {{domxref("Clipboard.write", "navigator.clipboard.write()")}} do not. For example, on Firefox at the time of writing, {{domxref("Clipboard.read", "navigator.clipboard.read()")}} and {{domxref("Clipboard.write", "navigator.clipboard.write()")}} are not fully implemented, such that to:
-
-- work with images use {{WebExtAPIRef("clipboard.setImageData","browser.clipboard.setImageData()")}} to write images to the clipboard and {{domxref("Document.execCommand()","document.execCommand("paste")")}} to paste images to a webpage.
-- write rich content (such as, HTML, rich text including images, etc.) to the clipboard, use {{domxref("Document.execCommand()","document.execCommand("copy")")}} or {{domxref("Document.execCommand()","document.execCommand("cut")")}}. Then, either {{domxref("Clipboard.read","navigator.clipboard.read()")}} (recommended) or {{domxref("Document.execCommand()","document.execCommand("paste")")}} to read the content from the clipboard.
+> [!NOTE]
+> The Clipboard API write and read methods are only available in [secure contexts](/en-US/docs/Web/Security/Secure_Contexts). Your extension can't use them from a content script running on `http:` pages; they can only use them from `https:` pages.
## Writing to the clipboard
-This section describes the options for writing data to the clipboard.
-
-### Using the Clipboard API
-
-The Clipboard API writes arbitrary data to the clipboard from your extension. Using the API requires the permission `"clipboardRead"` or `"clipboardWrite"` in your `manifest.json` file. As the API is only available to [Secure Contexts](/en-US/docs/Web/Security/Defenses/Secure_Contexts), it cannot be used from a content script running on `http:`-pages, only `https:`-pages.
-
-For page scripts, the `"clipboard-write"` permission needs to be requested using the Web API {{domxref("Permissions", "navigator.permissions")}}. You can check for that permission using {{domxref("Permissions.query", "navigator.permissions.query()")}}:
-
-```js
-navigator.permissions.query({ name: "clipboard-write" }).then((result) => {
- if (result.state === "granted" || result.state === "prompt") {
- /* write to the clipboard now */
- }
-});
-```
+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 only function after the extension's user performs {{Glossary("Transient Activation","transient activation")}}. However, with the [`"clipboardWrite"` permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite), transient activation isn't required.
> [!NOTE]
-> The `clipboard-write` permission name is not supported in Firefox, only Chromium browsers.
+> In Firefox and Chrome, the `"clipboardWrite"` permission enables writing to the clipboard from all extension contexts and content scripts. In Safari, the `"clipboardWrite"` permission is only supported in extension contexts (not content scripts).
This function takes a string and writes it to the clipboard:
@@ -63,9 +45,12 @@ function updateClipboard(newClip) {
### Using execCommand()
-The `"cut"` and `"copy"` commands of the {{domxref("Document.execCommand", "document.execCommand()")}} method are used to replace the clipboard's content with the selected material. These commands can be used without any special permission in short-lived event handlers for a user action (for example, a click handler).
+> [!NOTE]
+> {{domxref("Document.execCommand()","document.execCommand("copy")")}} and {{domxref("Document.execCommand()","document.execCommand("cut")")}} are deprecated and no longer guaranteed to work or be available on any browser.
+
+The `"cut"` and `"copy"` commands of the {{domxref("Document.execCommand", "document.execCommand()")}} method are used to replace the clipboard's content with the selected material. Extensions can use these commands without special permission in short-lived event handlers triggered by user actions (for example, a click handler).
-For example, suppose you've got a popup that includes the following HTML:
+For example, suppose you've got a popup that includes this HTML:
```html
@@ -83,9 +68,9 @@ function copy() {
document.querySelector("#copy").addEventListener("click", copy);
```
-Because the `execCommand()` call is inside a click event handler, you don't need any special permissions.
+Because the `execCommand()` call is inside a click event handler, your extension doesn't need special permissions.
-However, let's say that instead you trigger the copy from an alarm:
+However, take the example of your extension triggering the copy from an alarm:
```js
function copy() {
@@ -101,38 +86,25 @@ browser.alarms.create({
browser.alarms.onAlarm.addListener(copy);
```
-Depending on the browser, this may not work. On Firefox, it will not work, and you'll see a message like this in your console:
+Depending on the browser, this may not work. On Firefox, it doesn't work, and you see a message like this in the console:
`document.execCommand('cut'/'copy') was denied because it was not called from inside a short running user-generated event handler.`
-To enable this use case, you need to ask for the `"clipboardWrite"` [permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions). So: `"clipboardWrite"` enables you to write to the clipboard outside a short-lived event handler for a user action.
+To enable this use case, your extension must request the `"clipboardWrite"` [permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions): `"clipboardWrite"` enables your extension to write to the clipboard outside a short-lived event handler for a user action.
> [!NOTE]
-> {{domxref("Document.execCommand", "document.execCommand()")}} does not work on input fields of `type="hidden"`, with the HTML5 attribute `"hidden"`, or any matching CSS rule using `"display: none;"`. So, to add a "copy to clipboard" button to a `span`, `div`, or `p` tag, you need to use a workaround, such as setting the input's position to absolute and moving it out of the viewport.
-
-### Browser-specific considerations
-
-The clipboard and other APIs involved here are evolving rapidly, so there are variations among browsers in how they work.
-
-In Chrome:
-
-- You don't need `"clipboardWrite"`, even to write to the clipboard outside a user-generated event handler.
-
-In Firefox:
-
-- {{domxref("Clipboard.write", "navigator.clipboard.write()")}} is not supported.
-
-See the [browser compatibility tables](#browser_compatibility) for more information.
+> {{domxref("Document.execCommand", "document.execCommand()")}} doesn't work on input fields of `type="hidden"`, with the HTML5 attribute `"hidden"`, or any matching CSS rule using `"display: none;"`. To add a "copy to clipboard" button to a `span`, `div`, or `p` tag, you need to use a workaround, such as setting the input's position to absolute and moving it out of the viewport.
## Reading from the clipboard
-This section describes the options for reading or pasting data from the clipboard.
+The Clipboard API methods {{domxref("Clipboard.read", "navigator.clipboard.read()")}} and {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} read arbitrary text or binary data from the clipboard. These methods allow extensions to access data in the clipboard without pasting it into an editable element.
-### Using the Clipboard API
+The methods are available from a secure context but only function after the extension's user performs {{Glossary("Transient Activation","transient activation")}} and clicks a paste prompt in an ephemeral context menu. However, with the [`"clipboardRead"` permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardRead), your extension can read from the clipboard without user confirmation or transient activation.
-The Clipboard API's {{domxref("Clipboard.readText", "navigator.clipboard.readText()")}} and {{domxref("Clipboard.read", "navigator.clipboard.read()")}} methods let you read arbitrary text or binary data from the clipboard in [secure contexts](/en-US/docs/Web/Security/Defenses/Secure_Contexts). This lets you access the data in the clipboard without pasting it into an editable element.
+> [!NOTE]
+> In Firefox and Chrome, the `"clipboardRead"` permission enables writing to the clipboard from all extension contexts and content scripts. Safari doesn't support the `"clipboardRead"` permission.
-Once you have the `"clipboard-read"` permission from the [Permissions API](/en-US/docs/Web/API/Permissions_API), you can read from the clipboard easily. For example, this snippet of code fetches the text from the clipboard and replaces the contents of the element with the ID `"outbox"` with that text.
+This snippet of code fetches the text from the clipboard and replaces the contents of the element with the ID `"outbox"` with that text.
```js
navigator.clipboard
@@ -142,9 +114,12 @@ navigator.clipboard
### Using execCommand()
-To use {{domxref("Document.execCommand()","document.execCommand("paste")")}} your extension needs the `"clipboardRead"` [permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions). This is the case even if you're using the `"paste"` command from within a user-generated event handler, such as {{domxref("Element/click_event", "click")}} or {{domxref("Element/keypress_event", "keypress")}}.
+> [!NOTE]
+> {{domxref("Document.execCommand()","document.execCommand("paste")")}} is deprecated and no longer guaranteed to work or be available on any browser.
+
+To use {{domxref("Document.execCommand()","document.execCommand("paste")")}}, your extension needs the `"clipboardRead"` [permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions). This requirement exists even if you're using the `"paste"` command from within a user-generated event handler, such as {{domxref("Element/click_event", "click")}} or {{domxref("Element/keypress_event", "keypress")}}.
-Consider HTML that includes something like this:
+Consider HTML that includes this:
```html
@@ -159,13 +134,35 @@ function paste() {
document.execCommand("paste");
console.log(pasteText.textContent);
}
-
document.querySelector("#paste").addEventListener("click", paste);
```
### Browser-specific considerations
-Firefox supports the `"clipboardRead"` [permission](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions) from version 54 but only supports pasting into elements in [content editable mode](/en-US/docs/Web/HTML/Reference/Global_attributes/contenteditable), which for content scripts only works with a {{HTMLElement("textarea")}}. For background scripts, any element can be set to content editable mode.
+In Chrome:
+
+- Chrome doesn't expose `navigator.clipboard` to extension service workers, and offscreen documents can't access `navigator.clipboard` due to the API's document focus requirements. As a result, Chrome extensions have to use the deprecated `document.execCommand()` APIs in an offscreen document or use `navigator.clipboard` in a different context, such as a content script or extension page.
+ For page scripts to write to the clipboard without user interaction, the `"clipboard-write"` permission needs to be requested using the Web API {{domxref("Permissions", "navigator.permissions")}}. Your extension can check for that permission using {{domxref("Permissions.query", "navigator.permissions.query()")}}:
+
+ ```js
+ navigator.permissions.query({ name: "clipboard-write" }).then((result) => {
+ if (result.state === "granted" || result.state === "prompt") {
+ /* write to the clipboard now */
+ }
+ });
+ ```
+
+ > [!NOTE]
+ > The `clipboard-write` permission is not supported in Firefox or Safari.
+
+In Firefox:
+
+- The availability of the Clipboard API read methods on the user's response to a paste prompt was introduced for web pages in Firefox 127 and extensions in Firefox 147. Before that, the methods were only available when the `"clipboardRead"` permission was set.
+
+In Safari:
+
+- The `"clipboardWrite"` permission is only supported in extension contexts (not content scripts).
+- The `"clipboardRead"` permission isn't support.
## Browser compatibility
diff --git a/files/en-us/mozilla/add-ons/webextensions/manifest.json/permissions/index.md b/files/en-us/mozilla/add-ons/webextensions/manifest.json/permissions/index.md
index 023eab229abb534..fb3e61e7db6fb6b 100644
--- a/files/en-us/mozilla/add-ons/webextensions/manifest.json/permissions/index.md
+++ b/files/en-us/mozilla/add-ons/webextensions/manifest.json/permissions/index.md
@@ -182,12 +182,12 @@ Usually, the tab that's granted `activeTab` is the active tab, with one exceptio
## Clipboard access
-There are two permissions which enables the extension to interact with the clipboard:
+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")`
+ - : Write to the clipboard using {{DOMxRef("Clipboard.write()")}}, {{DOMxRef("Clipboard.writeText()")}}, `document.execCommand("copy")` or `document.execCommand("cut")`.
- `clipboardRead`
- - : Read from the clipboard using {{DOMxRef("Clipboard.read()")}}, {{DOMxRef("Clipboard.readText()")}} or `document.execCommand("paste")`
+ - : Read from the clipboard using {{DOMxRef("Clipboard.read()")}}, {{DOMxRef("Clipboard.readText()")}} or `document.execCommand("paste")`.
See [Interact with the clipboard](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard) for more details.
diff --git a/files/en-us/mozilla/firefox/releases/147/index.md b/files/en-us/mozilla/firefox/releases/147/index.md
index fef9e1d994d0859..fa67d6899cada39 100644
--- a/files/en-us/mozilla/firefox/releases/147/index.md
+++ b/files/en-us/mozilla/firefox/releases/147/index.md
@@ -90,6 +90,7 @@ No notable changes.
## 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 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))
- Temporarily loaded Manifest Version 3 extensions can now load scripts from localhost, as explained in [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in the Content Security Policy article. ([Firefox bug 1864284](https://bugzil.la/1864284))
## Experimental web features
diff --git a/files/en-us/web/api/clipboard_api/index.md b/files/en-us/web/api/clipboard_api/index.md
index 1ddffb9f46744d8..a0be1b5a4db14ad 100644
--- a/files/en-us/web/api/clipboard_api/index.md
+++ b/files/en-us/web/api/clipboard_api/index.md
@@ -80,12 +80,10 @@ Firefox & Safari:
- The paste-prompt is suppressed if reading same-origin clipboard content, but not cross-origin content.
- 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):
-- Reading text is only available for extensions with the Web Extension [`clipboardRead`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardread) permission.
- With this permission the extension does not require transient activation or a paste prompt.
-- Writing text is available in secure context and with transient activation.
- With the Web Extension [`clipboardWrite`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite) permission transient activation is not required.
+- Reading is available to extensions with the web extension [`clipboardRead`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardread) permission. With this permission, the extension doesn't require transient activation or use the paste prompt. From Firefox 147, reading is also available without the permission in a secure context, with transient activation, and after the user clicks the paste prompt in an ephemeral context menu.
+- Writing is available in a secure context and with transient activation. However, with the web extension [`clipboardWrite`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite) permission transient activation is not required.
## Examples
diff --git a/files/en-us/web/css/reference/at-rules/@custom-media/index.md b/files/en-us/web/css/reference/at-rules/@custom-media/index.md
index 05743d37359c0db..1db5f8cae5b5f1f 100644
--- a/files/en-us/web/css/reference/at-rules/@custom-media/index.md
+++ b/files/en-us/web/css/reference/at-rules/@custom-media/index.md
@@ -42,7 +42,10 @@ The `@custom-media` at-rule solves this problem by letting you define **named al
Custom media queries can be composed from others by referencing their alias names inside the media query features. This enables building more expressive, layered conditions. However, a custom media query cannot refer to itself, nor can it form part of a circular chain of references. Any circular dependency — direct or indirect — invalidates all custom media queries involved in that loop.
-If multiple `@custom-media` rules define the same `` name, only the last declaration in the source order applies. All earlier declarations are ignored.
+If multiple `@custom-media` rules define the same `` name, the rule
+that is in scope at the time a `@media` rule is evaluated is used. Earlier
+references are not retroactively updated when a later `@custom-media` rule is
+declared.
### Evaluating media queries with logical operators
@@ -222,7 +225,20 @@ In this example, one `@custom-media` rule is overridden by another `@custom-medi
@custom-media --mobile-breakpoint (width < 480px);
```
-The initial definition of `--mobile-breakpoint` is overridden and therefore ignored. The final declaration becomes the active value used by all references to that custom media query.
+When multiple `@custom-media` rules use the same name, the rule that is in scope
+at the time a `@media` rule is evaluated is used. Earlier references are not
+retroactively updated when a later `@custom-media` rule is declared.
+
+For example, in the code above, the `--mobile-breakpoint` reference inside the
+`@media` rule is evaluated as `(width < 320px)`, so the `.container` rule is only
+applied when the viewport is less than 320px wide, even though
+`--mobile-breakpoint` is redefined as `(width < 480px)` later in the stylesheet.
+
+> [!NOTE]
+> The overriding behavior of `@custom-media` is still under discussion in the CSS
+> specification and may change in the future. See the
+> [Browser compatibility](#browser_compatibility) section for current support
+> status.
## Specifications
diff --git a/files/en-us/web/http/reference/headers/permissions-policy/bluetooth/index.md b/files/en-us/web/http/reference/headers/permissions-policy/bluetooth/index.md
index 487ef2455fa37b2..03ec559ab74a330 100644
--- a/files/en-us/web/http/reference/headers/permissions-policy/bluetooth/index.md
+++ b/files/en-us/web/http/reference/headers/permissions-policy/bluetooth/index.md
@@ -30,36 +30,37 @@ Permissions-Policy: bluetooth=;
## Default policy
-The default allowlist for `bluetooth` is `self`.
+The default allowlist for `bluetooth` is `self`. The top-level browsing context and same-origin iframes are allowed access to the `bluetooth` feature by default.
## Examples
-### General example
+### Basic usage
-SecureCorp Inc. wants to disable the Web Bluetooth API within all browsing contexts except for its own origin and those whose origin is `https://example.com`.
-It can do so by delivering the following HTTP response header to define a Permissions Policy:
+SecureCorp Inc. wants to disallow `bluetooth` within all cross-origin iframes except those whose origin is `https://example.com`. It can do so by delivering the following HTTP response header to define a Permissions Policy:
```http
Permissions-Policy: bluetooth=(self "https://example.com")
```
-### With an \