Clarity about how to make HTTP requests from extension background scripts
- Dominant language
- Markdown
- Stars
- 11k
- Forks
- 23.2k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 331
Description
### MDN URL
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts
### What specific section or headline is this issue about?
XHR and Fetch
### What information was incorrect, unhelpful, or incomplete?
I wanted to understand how to make an HTTP request in the context of a certain domain from a background script.
Where I looked:
Add-ons → Browser extensions → JavaScript APIs
Add-ons → Browser extensions → JavaScript APIs → webRequest
Where some of the information was
Add-ons → Browser extensions → Concepts → Content scripts → XHR and Fetch (despite applying to background scripts as well)
What was missing entirely:
1. It isn't explained what "privileged XHR and fetch instances" exactly are
2. It isn't clear whether setting an Origin header to a certain domain would cause the cookies for that domain to be sent along
3. The fact that it's currently not possible to explicitly specify a cookieStore, etc. See https://bugzilla.mozilla.org/show_bug.cgi?id=1670278
### What did you expect to see?
This would be helpful:
1. A note on the "JavaScript APIs → webRequest" page about where to read about *making* requests
2. An elaboration on privileged XHR/fetch
3. An elaboration on cookies sent along with background script XHR/fetch
4. A warning that explicit specification of cookieStore is not possible right now
It might also make sense to split the XHR/fetch topic out into a separate page that can be found in the left sidebar
### Do you have any supporting links, references, or citations?
_No response_
### Do you have anything more you want to share?
_No response_
### MDN metadata
Page report details
* Folder: `en-us/mozilla/add-ons/webextensions/content_scripts`
* MDN URL: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts
* GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/mozilla/add-ons/webextensions/content_scripts/index.md
* Last commit: https://github.com/mdn/content/commit/ea7b9a1f2bcf8a909aa293211cc1731c84d95312
* Document last modified: 2023-04-25T15:28:57.000Z
Contributor guide
Assessment
This issue has not been assessed yet.