addons-linter icon indicating copy to clipboard operation
addons-linter copied to clipboard

Consider introducing a new error code for optional-only permissions

Open rpl opened this issue 10 months ago • 2 comments

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).

rpl avatar Jan 21 '25 14:01 rpl

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

Rob--W avatar Jan 30 '25 13:01 Rob--W

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

Rob--W avatar Feb 27 '25 13:02 Rob--W