Skip to content

Conversation

@rebloor
Copy link
Contributor

@rebloor rebloor commented Dec 15, 2025

Description

Address is the dev-docs-needed require requirements of Bug 1864284 Allow localhost in MV3 CSP to allow connecting to local dev servers with the addition of:

  • Notes in the default content security policy page and the manifest content security key page
  • release note

Related issues and pull requests

See related BCD changes in mdn/browser-compat-data#28683

@rebloor rebloor requested a review from Rob--W December 15, 2025 17:42
@rebloor rebloor self-assigned this Dec 15, 2025
@rebloor rebloor requested review from a team as code owners December 15, 2025 17:42
@rebloor rebloor added the Content:WebExt WebExtensions docs label Dec 15, 2025
@rebloor rebloor requested review from dipikabh and removed request for a team December 15, 2025 17:42
@github-actions github-actions bot added Content:Firefox Content in the Mozilla/Firefox subtree size/s [PR only] 6-50 LoC changed labels Dec 15, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

Preview URLs

External URLs (1)

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

(comment last updated: 2026-01-02 17:45:20)

- Directives that reference code – {{CSP("script-src")}}, {{CSP("script-src-elem")}}, {{CSP("worker-src")}}, and {{CSP("default-src")}} (if used as a fallback) – share the same secure source requirement. There are no restrictions on CSP directives that cover non-script content, such as {{CSP("img-src")}}.

In Manifest V3, all CSP sources that refer to external or non-static content are forbidden. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`.
In Manifest V3, all CSP sources that refer to external or non-static content are forbidden. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`. However, during development, you can access the localhost for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147 by setting the origin as `localhost` or `127.0.0.1`.
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 shorten the new addition and link to the new section in the other article? We only need to mention the option, the other section can be used to explain how to do so, along with details on the constraints.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Rob--W while I would usually err on the side of avoiding "documenting everything everywhere". However, forcing someone to follow a link for more information when the relevant information can be stated in one sentence and the linked content doesn't say much more seems unnecessary. I've added a for more information link here and for the comment around line 168. Github wouldn't let me apply your second suggestion as, for some reason, it considers the line to be deleted.

Image

```

- Manifest V3 does not allow remote URLs in `script-src` of `extension_pages`.
- Manifest V3 does not allow remote URLs in `script-src` of `extension_pages`. However, the localhost can be accessed during development for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147:
Copy link
Member

Choose a reason for hiding this comment

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

Shorten and link to the article for details.

Suggested change
- Manifest V3 does not allow remote URLs in `script-src` of `extension_pages`. However, the localhost can be accessed during development for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147:
- Manifest V3 does not allow remote URLs in `script-src` of `extension_pages`. An exception exists for localhost during debugging, see [Scripts from localhost at Content Security Policy](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost).

@rebloor rebloor requested a review from Rob--W December 30, 2025 18:04
- Directives that reference code – {{CSP("script-src")}}, {{CSP("script-src-elem")}}, {{CSP("worker-src")}}, and {{CSP("default-src")}} (if used as a fallback) – share the same secure source requirement. There are no restrictions on CSP directives that cover non-script content, such as {{CSP("img-src")}}.

In Manifest V3, all CSP sources that refer to external or non-static content are forbidden. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`.
In Manifest V3, all CSP sources that refer to external or non-static content are forbidden. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`. However, during development, you can access the localhost for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147 by setting the origin as `localhost` or `127.0.0.1`. See [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.
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
In Manifest V3, all CSP sources that refer to external or non-static content are forbidden. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`. However, during development, you can access the localhost for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147 by setting the origin as `localhost` or `127.0.0.1`. See [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.
In Manifest V3, all CSP sources that refer to external or non-static content are forbidden in CSP directives covering script content. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`. An exception exists for scripts from localhost during development; see [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.

Edit:

  • change the overly broad "are forbidden" to "are forbidden in CSP directives covering script content". This issue existed before, I'm improving it since I'm looking at it anyway.
  • "access" is broad too, it is not about access (which can also include sending a network request to that target), we are really specific about script execution in extension contexts.
  • Cut most of the text and point to the single article. We don't want to encourage allowing localhost; we just want to mention the possibility and refer to the single place for more information. Also, "localhost" and "127.0.0.1" are technically not origins, but domains at best.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
In Manifest V3, all CSP sources that refer to external or non-static content are forbidden. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`. However, during development, you can access the localhost for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147 by setting the origin as `localhost` or `127.0.0.1`. See [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.
In Manifest V3, all CSP sources that refer to external or non-static content are forbidden in CSP directives covering script content. The only permitted values are `'none'`, `'self'`, and `'wasm-unsafe-eval'`. There is an exception for scripts from localhost during development; see [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.

}
```

However, localhost can be accessed during development for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147. See [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.
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
However, localhost can be accessed during development for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147. See [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.
However, scripts from localhost can be allowlisted during development for unpacked extensions from Chrome 110 and temporarily loaded extensions from Firefox 147. See [Scripts from localhost](/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy#scripts_from_localhost) in Content Security Policy for more information.

@rebloor rebloor merged commit 6496974 into mdn:main Jan 2, 2026
7 checks passed
@rebloor rebloor deleted the Bug-1864284-Allow-localhost-access-for-temporary-MV3-add-on branch January 2, 2026 17:53
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:WebExt WebExtensions docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants