"about" in a host permission

The attached extension requests the invalid host permisson “xyz”.

Host Permission Regexp.zip (2.3 KB)

When it’s loaded as a temporary add-on, FF displays a warning/error.

Warning details

Reading manifest: Warning processing host_permissions: Error processing host_permissions.0: Value “xyz” must either: be one of ["<all_urls>"], must either [match the pattern /^(https?|wss?|file|ftp|*)://(*|*.[^/]+|[^/]+)/.$/, or match the pattern /^file:///.$/], or match the pattern /^resource://(*|*.[^/]+|[^/]+)/.*$|^about:/

According to the last part, “about:” should be a valid match pattern.

or match the pattern /^resource://(|.[^ /]+|[^ /]+)/.*$|^about:

But the host permission “about:” just causes another error.

Warning details

Reading manifest: Invalid extension permission: about:

Do I need to set a flag in about:config to use the host permission “about:”?
Or is the first error message wrong/misleading?

Realistically, there is only one “about” page that is “accessible” by addons, the “about:blank”, or maybe also “about:srcdoc”?

So, maybe if you write the whole URL?
Also, I’m not sure what you are up to, but maybe this will help:

1 Like

I think the error message is just wrong/confusing, resource and about matching is limited to privileged extensions: https://searchfox.org/mozilla-central/rev/5049886134b906888fe78428bd298a94c4ee721e/toolkit/components/extensions/schemas/manifest.json#666

3 Likes

That sounds like a question :slight_smile:

FF MV3 lets the user toggle an extension’s optional permissions in about:addons

I want to warn the user if they

  • disable a permission the extension currently needs
  • enable a permission the extension currently doesn’t need
browser.permissions.onAdded.addListener(async permissions => {
    let [ active_tab ] = await browser.tabs.query({ lastFocusedWindow: true, active: true });
    if (active_tab.url === "about:addons") {
        // If the extension doesn't need the permission, warn the user
        console.log("permissions.onAdded - check if we need to warn the user");
    }
    else {
        console.log("permissions.onAdded - don't warn the user");
    }
})

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs

To access Tab.url, Tab.title, and Tab.favIconUrl (or to filter by these properties via tabs.query()), you need to have the “tabs” permission, or have host permissions that match Tab.url.

With an “about:addons” host permission, I wouldn’t need the “tabs” permission.
But I can live with requiring the “tabs” permission in this case.

1 Like

Thank you, this answers my question!