addons-linter
addons-linter copied to clipboard
Consider introducing a new error code for optional-only permissions
As a followup to #5551 we want to consider introducing a new error code to be associated to optional-only permissions being requested as non-optional.
Reasons for introducing a new error code would be:
- make it clear when a permission is invalid because non supported by Firefox vs. when it is invalid because it can only requested as optional
- point developers to a doc page describing in a bit more details how developers should use optional-only permissions (and how that differs from other optional permissions).
We have a stub for MDN documentation, which we should link that from the dedicated message: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions#optional-only_permissions
The current warning is Invalid permissions "${permName}", associated with the permissions manifest key.
This message is confusing. It would be nice if the message is more specific, e.g. Permission "${permName}" is only supported in optional_permissions.
In Chrome, userScripts permission has to be in permissions (or optional_permissions), in Firefox it can only be in optional_permissions. An extension that would like to have a cross-browser compatible extension would put the permission in both permissions and optional_permissions. In that case, we should ideally not warn.
(we have a similar situation where we should warn, optional_permissions vs optional_host_permissions, see #5329)
Relevant unit test (from PR #5551) is at https://github.com/mozilla/addons-linter/blob/2b56dc60108f105792db0f4660db42ccc571233f/tests/unit/parsers/test.manifestjson.js#L1380-L1401