Manifest V3 (MV3) is bringing new user-facing changes to Firefox, including an extensions button to manage installed and enabled browser extension permissions (origin controls), providing Firefox users control over extension access to their browsers. The first building blocks of this button were added to Nightly in Firefox 107 and will become available with the general release of MV3 in Firefox 109.
Extensions button
In MV2, host permissions are granted by the user at the time of install and there’s no elegant way for the user to change this setting (short of uninstalling/reinstalling and choosing different permissions). But with the new extensions button in MV3 in Firefox, users will have easy access and persistent control over which extensions can access any web page, at any time. Users are free to grant ongoing access to a website, or make a choice per visit. To enable this, MV3 treats host permissions (listed in the extension manifest) as opt-in.
The button panel will display the user’s installed and enabled extensions and their current permission state. In addition to managing host permissions, the panel also allows the user to manage, remove, or report the extension. Extensions with browser actions will behave similarly in the toolbar as in the panel.
Manifest V2 (MV2) extensions will also display in the panel; however users can’t take actions for MV2 host permissions since those were granted at installation and this choice cannot be reversed in MV2 without uninstalling the extension and starting again.
You can also find more information about the extensions button from support.mozilla.org
How to deal with opt-in permissions in extension code
The Permissions API provides a way for developers to read and request permissions.
With permissions.request(), you can request specific permissions that have been defined as optional permissions in the manifest:
const permissionsToRequest = {
permissions: ["bookmarks", "history"],
origins: ["https://developer.mozilla.org/"]
}
async function requestPermissions() {
function onResponse(response) {
if (response) {
console.log("Permission was granted");
} else {
console.log("Permission was refused");
}
return browser.permissions.getAll();
}
const response = await browser.permissions.request(permissionsToRequest);
const currentPermissions = await onResponse(response);
console.log(`Current permissions:`, currentPermissions);
}
This is handy when the request for permissions is tied to a user action like selecting a context menu item. Note that you cannot request for a permission that is not defined in the manifest.
Other times, you’ll want to react to a permission being granted or removed. This can be done with permissions.onAdded and permissions.onRemoved respectively.
function handleAdded(permissions) {
console.log(`New API permissions: ${permissions.permissions}`);
console.log(`New host permissions: ${permissions.origins}`);
}
browser.permissions.onAdded.addListener(handleAdded);
Finally, you can check for already existing permissions in two different ways: permissions.getAll() returns a list of all granted permissions and permissions.contains(permissionsToCheck) checks for specific permissions and resolves to true if, and only if, all checked permissions are granted.
// Extension permissions are:
// "webRequest", "tabs", "*://*.mozilla.org/*"
let testPermissions1 = {
origins: ["*://mozilla.org/"],
permissions: ["tabs"]
};
const testResult1 = await browser.permissions.contains(testPermissions1);
console.log(testResult1); // true
We always encourage feedback from our developer community, so don’t hesitate to get in touch:
- Chat: chat.mozilla.org
- Report issues and ask questions on Discourse (where knowledge may be shared among other developers)
- Report problems on: Bugzilla
Max wrote on
Juha-Matti Santala wrote on
Habi wrote on
Juha-Matti Santala wrote on
Mark wrote on
Juha-Matti Santala wrote on
Mark wrote on
Juha-Matti Santala wrote on
Mark wrote on
Mark wrote on
Juha-Matti Santala wrote on
Jose wrote on
Juha-Matti Santala wrote on
Jose wrote on
Chris wrote on
Juha-Matti Santala wrote on
Chris wrote on
Juha-Matti Santala wrote on
Andraste Melánie wrote on
Juha-Matti Santala wrote on
Finn wrote on
Omar Enrique wrote on
Juha-Matti Santala wrote on
Pavel wrote on
Juha-Matti Santala wrote on
Paweł wrote on
Juha-Matti Santala wrote on
Paweł wrote on
Paweł wrote on
Juha-Matti Santala wrote on
Pascal wrote on
curious user wrote on
Juha-Matti Santala wrote on
Mark wrote on
Dre wrote on
krrr wrote on
Samuel wrote on
Mic wrote on
Finn wrote on