Open Bug 1827855 Opened 2 years ago Updated 1 year ago

[DNR] Support declarativeNetRequest and declarativeNetRequestWithHostAccess as an optional permission

Categories

(WebExtensions :: Request Handling, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [addons-jira])

The declarativeNetRequest and declarativeNetRequestWithHostAccess permission can currently only be declared in permissions, not in optional_permissions. It would be useful if extensions can declare declarativeNetRequest as an optional permission (because it has a permission warning).

From the implementation POV, them being non-optional means that the implementation can assume the permission/feature to either be available to the extension or be permanently unavailable. That is relied upon at e.g. https://searchfox.org/mozilla-central/rev/ad732108b073742d7324f998c085f459674a6846/toolkit/components/extensions/ExtensionDNR.sys.mjs#2285-2290.

If we make these permissions optional, we should:

  • initialize the DNR engine for the extension if that has not happened yet (i.e. load saved static/dynamic rules)
  • unregister and unload the DNR rules if all permissions have been revoked (i.e. unregister the RuleManager and its session/dynamic/static rules from ExtensionDNR), and possibly even delete all saved dynamic and static rules from the disk (at least from the startupCache, likely also the StoreData on disk).
  • Ensure that the implementation does not blow up when the DNR engine is (re)loaded. Note that extensions can already restart themselves with browser.runtime.reload(), so the browser should already be prepared to handle this correctly.

For comparison, Chrome's behavior is as follows:

P.S. The declarativeNetRequestFeedback permission is not mentioned because it is already optional, in Firefox (bug 1811947) and in Chrome.

See Also: → 1827858
Severity: -- → N/A
Priority: -- → P3

FYI: there is a similar feature request in Chrome at https://bugs.chromium.org/p/chromium/issues/detail?id=893924 - "Issue 893924: Declarative Net Request: Add support for "declarativeNetRequest" permission to be optional."

You need to log in before you can comment on or make changes to this bug.