Clarify the different ways that "matches patterns" are used
- Dominant language
- Markdown
- Stars
- 11k
- Forks
- 23.2k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 331
Description
_Derived from a comment by @dotproto in https://github.com/mdn/content/pull/36069#pullrequestreview-2459791819_
While reviewing PR #36069 I realized that my feedback was focused on how match patterns are used for (optional) host permissions declarations in the extension manifest. Unfortunately, that's just one of several ways that match patterns are used in extensions.
This is a non-exhaustive list of WebExtensions API surfaces that use match patterns. At the moment the exact differences between how these various surfaces use match patterns is unclear.
1. host permissions declared in the `host_permissions` and `optional_host_permissions` manifest fields.
* same usage pattern should apply to the `origins` field of the object passed to [`permissions.request()`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/request)
2. the `matches` field of content script declarations
* should also apply to the `matches` field in the object passed to [`scripting.registerContentScripts()`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/registerContentScripts)
* should also match the `matches` field in the object passed to [`userScripts.register()`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts/register)
3. the `matches` as used in entries of the [`web_accessible_resources`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/web_accessible_resources#manifest_v3_syntax) manifest field (MV3 only).
4. In the `hide_matches` and `show_matches` fields of the [`page_action`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/page_action) manifest field.
5. the `url` field of the [`webRequest.RequestFilter`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/RequestFilter) object.
6. the `url` field of the filter object passed to [`tabs.onUpdated()`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated).
7. the `url` field of the options argument passed to [`tabs.query()`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query)
8. the `matches` field of the generic [`UrlFilter`](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/events/UrlFilter) object.
This list is non-exhaustive. I should go through searchfox.org and cs.chromium.org to look for additional uses I may have missed.
Contributor guide
Assessment
This issue has not been assessed yet.