From 1456c7342d722bcbe521ab04c2550b6cb39b1704 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 18:07:33 +0100 Subject: [PATCH 1/2] chore(deps-dev): bump lefthook from 2.0.16 to 2.1.0 (#43009) Bumps [lefthook](https://github.com/evilmartians/lefthook) from 2.0.16 to 2.1.0. - [Release notes](https://github.com/evilmartians/lefthook/releases) - [Changelog](https://github.com/evilmartians/lefthook/blob/master/CHANGELOG.md) - [Commits](https://github.com/evilmartians/lefthook/compare/v2.0.16...v2.1.0) --- updated-dependencies: - dependency-name: lefthook dependency-version: 2.1.0 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 88 +++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index 75f73f3bc4a9938..a74149efb078603 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,7 +34,7 @@ "imagemin-pngquant": "^10.0.0", "imagemin-svgo": "^11.0.1", "is-svg": "^6.1.0", - "lefthook": "^2.0.16", + "lefthook": "^2.1.0", "markdownlint-cli2": "0.20.0", "markdownlint-rule-search-replace": "1.2.0", "node-html-parser": "^7.0.2", @@ -6153,9 +6153,9 @@ } }, "node_modules/lefthook": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-2.0.16.tgz", - "integrity": "sha512-ABs3M5V9c4nqxFnZO509HXuQTu8GM8hmqc9ruV0acQ81yKlxEq70MRoYP5Z1dr5le326X8vA5qj3arJA36yE3A==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-2.1.0.tgz", + "integrity": "sha512-+vS+yywGQW6CN1J1hbGkez//6ixGHIQqfxDN/d3JDm531w9GfGt2lAWTDfZTw/CEl80XsN0raFcnEraR3ldw9g==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -6163,22 +6163,22 @@ "lefthook": "bin/index.js" }, "optionalDependencies": { - "lefthook-darwin-arm64": "2.0.16", - "lefthook-darwin-x64": "2.0.16", - "lefthook-freebsd-arm64": "2.0.16", - "lefthook-freebsd-x64": "2.0.16", - "lefthook-linux-arm64": "2.0.16", - "lefthook-linux-x64": "2.0.16", - "lefthook-openbsd-arm64": "2.0.16", - "lefthook-openbsd-x64": "2.0.16", - "lefthook-windows-arm64": "2.0.16", - "lefthook-windows-x64": "2.0.16" + "lefthook-darwin-arm64": "2.1.0", + "lefthook-darwin-x64": "2.1.0", + "lefthook-freebsd-arm64": "2.1.0", + "lefthook-freebsd-x64": "2.1.0", + "lefthook-linux-arm64": "2.1.0", + "lefthook-linux-x64": "2.1.0", + "lefthook-openbsd-arm64": "2.1.0", + "lefthook-openbsd-x64": "2.1.0", + "lefthook-windows-arm64": "2.1.0", + "lefthook-windows-x64": "2.1.0" } }, "node_modules/lefthook-darwin-arm64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-2.0.16.tgz", - "integrity": "sha512-kjVHkD7rfPa7M0aKJSx/yatdV9uC6o3cJyzM9zk7cg5HD7alSwchFalgF/P0w6nt7C02rAUx8C05qiWCDWaKeA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-darwin-arm64/-/lefthook-darwin-arm64-2.1.0.tgz", + "integrity": "sha512-u2hjHLQXWSFfzO7ln2n/uEydSzfC9sc5cDC7tvKSuOdhvBwaJ0AQ7ZeuqqCQ4YfVIJfYOom1SVE9CBd10FVyig==", "cpu": [ "arm64" ], @@ -6190,9 +6190,9 @@ ] }, "node_modules/lefthook-darwin-x64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-2.0.16.tgz", - "integrity": "sha512-tbJ0mdT49DNRLqknro0BvWrYNC23TTcqBJFQnQ32pq1/H9B87bTNKvKKAtogp/saxfHUzkIq1i3twZlBZ3G3Xw==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-darwin-x64/-/lefthook-darwin-x64-2.1.0.tgz", + "integrity": "sha512-zz5rcyrtOZpxon7uE+c0KC/o2ypJeLZql5CL0Y9oaTuECbmhfokm8glsGnyWstW/++PuMpZYYr/qsCJA5elxkQ==", "cpu": [ "x64" ], @@ -6204,9 +6204,9 @@ ] }, "node_modules/lefthook-freebsd-arm64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-2.0.16.tgz", - "integrity": "sha512-wa1KFD5tSUhw3tuetVef/BCSxbbmS7auTDNdoLx3WFeuN5RS15woSN9+E8GPGOOY1g2HCsgdLrhrexEomulfjQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-arm64/-/lefthook-freebsd-arm64-2.1.0.tgz", + "integrity": "sha512-+mXNCNuFHNGYLrDqYWDeHH7kWCLCJFPpspx5PAAm+PD37PRMZJrTqDbaNK9qCghC1tdmT4/Lvilf/ewXHPlaKw==", "cpu": [ "arm64" ], @@ -6218,9 +6218,9 @@ ] }, "node_modules/lefthook-freebsd-x64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-2.0.16.tgz", - "integrity": "sha512-UXowfn2e94AwNk9UuoePRK+qiF15jZsssiyA15VK5GTtxpn6Sn+Z2QFciofxJczXXxM4abaf7qgx2OoJBt32VA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-freebsd-x64/-/lefthook-freebsd-x64-2.1.0.tgz", + "integrity": "sha512-+AU2HD7szuDsUdHue/E3OnF84B2ae/h7CGKpuIUHJntgoJ4kxf89oDvq2/xl8kDCn9cT76UUjgeZUgFYLRj+6Q==", "cpu": [ "x64" ], @@ -6232,9 +6232,9 @@ ] }, "node_modules/lefthook-linux-arm64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-2.0.16.tgz", - "integrity": "sha512-U355elz4Z0AHSVqxfcglN09TGR86ov/GtYlliDknci2mmz6EWLiD3dTYnqJiwa4dYxqmuCDc/DvAL9rgb3YJiQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-linux-arm64/-/lefthook-linux-arm64-2.1.0.tgz", + "integrity": "sha512-KM70eV1tsEib1/tk+3TFxIdH84EaYlIg5KTQWAg+LB1N23nTQ7lL4Dnh1je6f6KW4tf21nmoMUqsh0xvMkQk8Q==", "cpu": [ "arm64" ], @@ -6246,9 +6246,9 @@ ] }, "node_modules/lefthook-linux-x64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-2.0.16.tgz", - "integrity": "sha512-7eAvBeWGAgjOKZ23OQbjJINLPImDIuDeX8dXOfk+aI6IFt2X6KCzRkp+ASUvGQtrPuNZQZT43EhW0/1jZU14ZQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-linux-x64/-/lefthook-linux-x64-2.1.0.tgz", + "integrity": "sha512-6Bxmv+l7LiYq9W0IE6v2lmlRtBp6pisnlzhcouMGvH3rDwEGw11NAyRJZA3IPGEMAkIuhnlnVTUwAUzKomfJLg==", "cpu": [ "x64" ], @@ -6260,9 +6260,9 @@ ] }, "node_modules/lefthook-openbsd-arm64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-openbsd-arm64/-/lefthook-openbsd-arm64-2.0.16.tgz", - "integrity": "sha512-Fcd+E17ZkWGnRSQINb5gf+rNy2So5PYn5mBljiC31dl+TgWM8Wy46mSEGveHo7lKCO3q+DkmHIa50Qm58G03AQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-openbsd-arm64/-/lefthook-openbsd-arm64-2.1.0.tgz", + "integrity": "sha512-ppJNK0bBSPLC8gqksRw5zI/0uLeMA5cK+hmZ4ofcuGNmdrN1dfl2Tx84fdeef0NcQY0ii9Y3j3icIKngIoid/g==", "cpu": [ "arm64" ], @@ -6274,9 +6274,9 @@ ] }, "node_modules/lefthook-openbsd-x64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-openbsd-x64/-/lefthook-openbsd-x64-2.0.16.tgz", - "integrity": "sha512-uL5nOkz8eBtQHped0/tB5X8clZ5kfnyjQrv1fpKbGAjeFHI2J+GmRqcn6Awq2IeuBbQvkyV6jDjpATyHBp5mCA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-openbsd-x64/-/lefthook-openbsd-x64-2.1.0.tgz", + "integrity": "sha512-8k9lQsMYqQGu4spaQ8RNSOJidxIcOyfaoF2FPZhthtBfRV3cgVFGrsQ0hbIi5pvQRGUlCqYuCN79qauXHmnL3Q==", "cpu": [ "x64" ], @@ -6288,9 +6288,9 @@ ] }, "node_modules/lefthook-windows-arm64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-2.0.16.tgz", - "integrity": "sha512-U61bNWzD6Vd2kjuJ7b4voPfTQ4mlBFOyTpCU3k/h0YjpKDQEFT1T5fDKkDothdnw/JVDSgrclIcfAY7Jyr/UIg==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-windows-arm64/-/lefthook-windows-arm64-2.1.0.tgz", + "integrity": "sha512-0WN+grrxt9zP9NGRcztoPXcz25tteem91rfLWgQFab+50csJ47zldlsB7/eOS/eHG5mUg5g5NPR4XefnXtjOcQ==", "cpu": [ "arm64" ], @@ -6302,9 +6302,9 @@ ] }, "node_modules/lefthook-windows-x64": { - "version": "2.0.16", - "resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-2.0.16.tgz", - "integrity": "sha512-dCHi2+hebhPI0LQUGRNjPMsGRyXhrTN3Y/b8M4HO8KVyGamKB3Yemf67ya81tZopDkxNVy5XUBXLYWKGhnAfLQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lefthook-windows-x64/-/lefthook-windows-x64-2.1.0.tgz", + "integrity": "sha512-XbO/5nAZQLpUn0tPpgCYfFBFJHnymSglQ73jD6wymNrR1j8I5EcXGlP6YcLhnZ83yzsdLC+gup+N6IqUeiyRdw==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index 93588a45c75e786..6e09fc795ee0af2 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "imagemin-pngquant": "^10.0.0", "imagemin-svgo": "^11.0.1", "is-svg": "^6.1.0", - "lefthook": "^2.0.16", + "lefthook": "^2.1.0", "markdownlint-cli2": "0.20.0", "markdownlint-rule-search-replace": "1.2.0", "node-html-parser": "^7.0.2", From aa2535b8d83223b53fe57bb0c3daaf1c6851d781 Mon Sep 17 00:00:00 2001 From: rebloor Date: Sat, 7 Feb 2026 06:53:07 +1300 Subject: [PATCH 2/2] Additional information for `data_collection_permissions` in `permissions` API (#43029) * Additional information for `data_collection_permissions` in `permissions` API * Clarification and typo * Feedback update (typo) Co-authored-by: William Durand --------- Co-authored-by: William Durand --- .../api/permissions/contains/index.md | 18 +++++---- .../api/permissions/getall/index.md | 9 ++--- .../webextensions/api/permissions/index.md | 39 +++++++++++-------- .../api/permissions/onadded/index.md | 5 ++- .../api/permissions/onremoved/index.md | 9 +++-- .../api/permissions/permissions/index.md | 4 +- .../api/permissions/remove/index.md | 10 ++--- .../api/permissions/request/index.md | 15 ++++--- .../browser_specific_settings/index.md | 2 +- 9 files changed, 63 insertions(+), 48 deletions(-) diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/contains/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/contains/index.md index f8bec5fe05a020a..6b6196e7c1d1978 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/contains/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/contains/index.md @@ -6,11 +6,7 @@ browser-compat: webextensions.api.permissions.contains sidebar: addonsidebar --- -Check whether the extension has the permissions listed in the given {{WebExtAPIRef("permissions.Permissions")}} object. - -The `Permissions` argument may contain either an origins property, which is an array of [host permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions), or a `permissions` property, which is an array of [API permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#api_permissions), or both. - -This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). The promise resolves to `true` if the extension has all of the specified permissions. For host permissions, if the extension's permissions [pattern-match](/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) the permissions listed in `origins`, then they are considered to match. +Checks whether the extension has specific permissions. ## Syntax @@ -27,17 +23,18 @@ let getContains = browser.permissions.contains( ### Return value -A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that will be fulfilled with `true` if the extension already has all the permissions listed in the `permissions` argument, or `false` otherwise. +A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with `true` if the extension has all the permissions listed in the `permissions` argument, or `false` otherwise. For host permissions, if the extension's permissions [pattern-match](/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns) the permissions listed in `origins`, then they are considered to match. ## Examples ```js // Extension permissions are: -// "webRequest", "tabs", "*://*.mozilla.org/*" +// "webRequest", "tabs", "*://*.mozilla.org/*", and "healthInfo" in "data_collection" let testPermissions1 = { origins: ["*://mozilla.org/"], permissions: ["tabs"], + data_collection: ["healthInfo"], }; const testResult1 = await browser.permissions.contains(testPermissions1); @@ -65,6 +62,13 @@ let testPermissions4 = { const testResult4 = await browser.permissions.contains(testPermissions4); console.log(testResult4); // false: "https://example.org/", `origins` doesn't match + +let testPermissions5 = { + data_collection: ["searchTerms"], +}; + +const testResult5 = await browser.permissions.contains(testPermissions4); +console.log(testResult5); // false: "searchTerms" doesn't match data type in `data_collection` ``` {{WebExtExamples}} diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/getall/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/getall/index.md index 34d2b3207923493..91397676509a075 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/getall/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/getall/index.md @@ -6,9 +6,7 @@ browser-compat: webextensions.api.permissions.getAll sidebar: addonsidebar --- -Retrieve a {{WebExtAPIRef("permissions.Permissions")}} object containing all the permissions currently granted to the extension. - -This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +Retrieves a {{WebExtAPIRef("permissions.Permissions")}} object containing all the permissions currently granted to the extension. ## Syntax @@ -22,18 +20,19 @@ None. ### Return value -A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that will be fulfilled with a {{WebExtAPIRef("permissions.Permissions")}} object containing all the permissions currently granted to the extension. This includes all permissions the extension has listed in the [`permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions) key, and any permissions listed in [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) that the extension has been granted by calling {{WebExtAPIRef("permissions.request()")}}. +A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with a {{WebExtAPIRef("permissions.Permissions")}} object containing all the permissions currently granted to the extension. This includes all permissions the extension has listed in the [`permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions) key, and any permissions listed in [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) that the extension has been granted by calling {{WebExtAPIRef("permissions.request()")}}. ## Examples ```js // Extension permissions are: -// "webRequest", "tabs", "*://*.mozilla.org/*" +// "webRequest", "tabs", "*://*.mozilla.org/*", and "healthInfo" in "data_collection" const currentPermissions = await browser.permissions.getAll(); console.log(currentPermissions.permissions); // [ "webRequest", "tabs" ] console.log(currentPermissions.origins); // [ "*://*.mozilla.org/*" ] +console.log(currentPermissions.data_collection); // [ healthInfo" ] ``` {{WebExtExamples}} diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/index.md index a31342ae6c2ac7d..df3f75c35736d69 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/index.md @@ -8,22 +8,29 @@ sidebar: addonsidebar Enables extensions to request extra permissions at runtime, after they have been installed. -Extensions need permissions to access more powerful WebExtension APIs. They can ask for permissions at install time, by including the permissions they need in the [`permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions) manifest.json key. The main advantages of asking for permissions at install time are: +Extensions need permissions to access more powerful WebExtension APIs. They can request permissions at install time by including them in the [`permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions) manifest.json key. The main advantages of asking for permissions at install time are: -- The user is only asked once, so it's less disruptive for them, and a simpler decision. -- The extension can rely on the access to the APIs it needs, because if already running, the permissions have been granted. +- The extension asks the user only once, so it's less disruptive for them, and a simpler decision. +- The extension can rely on the access to the APIs it needs, as it knows the permissions are granted. -In most major browsers, users can see if their installed extensions request advanced permissions through the browser's extensions manager. +In most major browsers, users can see if installed extensions request advanced permissions through the browser's extensions manager. -With the permissions API, an extension can ask for additional permissions at runtime. These permissions need to be listed in the [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) manifest.json key. Note that some permissions are not allowed in `optional_permissions`. The main advantages of this are: +Using the permissions API, an extension can request additional permissions at runtime. The extension must list these permissions in -- The extension can run with a smaller set of permissions, except when it actually needs them. -- The extension can handle permission denial in a graceful manner, instead of presenting the user with a global "all or nothing" choice at install time. You can still get a lot out of that map extension, without giving it access to your location, for example. -- The extension may need [host permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions), but not know at install time which host permissions it needs. For example, the list of hosts may be a user setting. In this scenario, asking for a more specific range of hosts at runtime, can be an alternative to asking for "\" at install time. +- [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) key of its manifest.json file for origins and API permissions. +- [`gecko.data_collection_permissions.optional`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#optional) property of the `browser_specific_settings` key of its manifest.json file for data collection permissions. -To use the permissions API, decide which permissions your extension can request at runtime, and list them in [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions). After this, you can request any permissions that were included in `optional_permissions`. Requests may only be made in the handler for a user action (for example, a click handler). +The main advantages of requesting permissions at runtime are: -Starting with Firefox 84, users will be able to manage optional permissions of installed extensions from the Add-ons Manager. Extensions that use optional permissions should listen for [browser.permissions.onAdded](/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/onAdded) and [browser.permissions.onRemoved](/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/onRemoved) API events to know when a user grants or revokes these permissions. +- The extension can run with a smaller set of permissions, except when it needs them. +- The extension can gracefully handle permission denial, instead of presenting the user with a global "all or nothing" choice at install time. For example, a user can get a lot out of that map extension without giving it access to their location. +- The extension may need [host permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions), but not know at install time which host permissions it needs. For example, the list of hosts may be a user setting. In this scenario, requesting a more specific range of hosts at runtime can be an alternative to asking for "\" at install time. + +Note that some permissions are not allowed in `optional_permissions`. + +To use the permissions API, decide which permissions your extension can request at runtime, and list them in [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) and [`browser_specific_settings.gecko.data_collection_permissions.optional`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#optional). After this, you can request any permissions included in `optional_permissions` or `browser_specific_settings.gecko.data_collection_permissions.optional`. The extension can only make these requests in the handler for a user action (for example, a click handler). + +Starting with Firefox 84, users can manage optional permissions of installed extensions from the Add-ons Manager. Extensions that use optional permissions should listen for [browser.permissions.onAdded](/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/onAdded) and [browser.permissions.onRemoved](/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/onRemoved) API events to know when a user grants or revokes these permissions. For advice on designing your request for runtime permissions, to maximize the likelihood that users grant them, see [Request permissions at runtime](https://extensionworkshop.com/documentation/develop/request-the-right-permissions/#request_permissions_at_runtime). @@ -35,20 +42,20 @@ For advice on designing your request for runtime permissions, to maximize the li ## Methods - {{WebExtAPIRef("permissions.contains()")}} - - : Discover an extension's given set of permissions. + - : Checks whether the extension has specific permissions. - {{WebExtAPIRef("permissions.getAll()")}} - - : Get all the permissions this extension currently has. + - : Retrieves all the permissions currently granted to the extension. - {{WebExtAPIRef("permissions.remove()")}} - - : Give up a set of permissions. + - : Givew up a set of permissions. - {{WebExtAPIRef("permissions.request()")}} - - : Ask for a set of permissions. + - : Asks for a set of permissions. ## Event handlers - {{WebExtAPIRef("permissions.onAdded")}} - - : Fired when a new permission is granted. + - : Fires when a user grants new permissions. - {{WebExtAPIRef("permissions.onRemoved")}} - - : Fired when a permission is removed. + - : Fires when a user revokes a permission. {{WebExtExamples("h2")}} diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/onadded/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/onadded/index.md index 8b4e40014b0398f..2bc50cfcd212a6a 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/onadded/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/onadded/index.md @@ -6,7 +6,7 @@ browser-compat: webextensions.api.permissions.onAdded sidebar: addonsidebar --- -Fired when the extension granted new permissions. +Fires when the extension is granted permissions. ## Syntax @@ -40,6 +40,9 @@ Events have three functions: function handleAdded(permissions) { console.log(`New API permissions: ${permissions.permissions}`); console.log(`New host permissions: ${permissions.origins}`); + console.log( + `New data collection permissions: ${permissions.data_collection}`, + ); } browser.permissions.onAdded.addListener(handleAdded); diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/onremoved/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/onremoved/index.md index 033ccca5328db50..ddf0b11349571d5 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/onremoved/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/onremoved/index.md @@ -6,7 +6,7 @@ browser-compat: webextensions.api.permissions.onRemoved sidebar: addonsidebar --- -Fired when some permissions are removed from the extension. +Fires when permissions are removed from the extension. ## Syntax @@ -21,9 +21,9 @@ Events have three functions: - `addListener(listener)` - : Adds a listener to this event. - `removeListener(listener)` - - : Stop listening to this event. The `listener` argument is the listener to remove. + - : Stops listening to this event. The `listener` argument is the listener to remove. - `hasListener(listener)` - - : Check whether `listener` is registered for this event. Returns `true` if it is listening, `false` otherwise. + - : Checks whether `listener` is registered for this event. Returns `true` if it is listening, `false` otherwise. ## addListener syntax @@ -40,6 +40,9 @@ Events have three functions: function handleRemoved(permissions) { console.log(`Removed API permissions: ${permissions.permissions}`); console.log(`Removed host permissions: ${permissions.origins}`); + console.log( + `Removed data collection permissions: ${permissions.data_collection}`, + ); } browser.permissions.onRemoved.addListener(handleRemoved); diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/permissions/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/permissions/index.md index 7da36092192edbe..d0d71d274703a19 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/permissions/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/permissions/index.md @@ -10,12 +10,14 @@ A `Permissions` object represents a collection of permissions. ## Type -An {{jsxref("object")}} with the following properties: +An {{jsxref("object")}} with these properties: - `origins` {{optional_inline}} - : An array of [match patterns](/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns), representing [host permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions). - `permissions` {{optional_inline}} - : An array of named permissions, including [API permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#api_permissions) and [clipboard permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboard_access). +- `data_collection` {optional_inline}} + - : An array of [data collection permissions types](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#data_collection_permissions). {{WebExtExamples}} diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/remove/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/remove/index.md index 5fe9e4bd3c88212..2bd807dbed6abfb 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/remove/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/remove/index.md @@ -6,11 +6,9 @@ browser-compat: webextensions.api.permissions.remove sidebar: addonsidebar --- -Ask to give up the permissions listed in the given {{WebExtAPIRef("permissions.Permissions")}} object. +Revokes the permissions listed in a {{WebExtAPIRef("permissions.Permissions")}} object. -The `Permissions` argument may contain either an `origins` property, which is an array of [host permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions), or a `permissions` property, which is an array of [API permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#api_permissions), or both. Permissions must come from the set of permissions defined in the [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) manifest.json key. - -This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +Permissions must come from those defined in the extension's [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) key or [`gecko.data_collection_permissions.optional`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#optional) property of the `browser_specific_settings` key of its manifest.json file. ## Syntax @@ -27,11 +25,11 @@ let removing = browser.permissions.remove( ### Return value -A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that is fulfilled with `true` if the permissions listed in the `permissions` argument are now not granted to the extension, or `false` otherwise. +A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with `true` if the browser is no longer granting the permissions listed in the `permissions` argument to the extension, or `false` otherwise. ## Examples -This code adds a click handler that removes a given permission. +This code adds a click handler that removes a permission. ```js const permissionToRemove = { diff --git a/files/en-us/mozilla/add-ons/webextensions/api/permissions/request/index.md b/files/en-us/mozilla/add-ons/webextensions/api/permissions/request/index.md index 001ef1f7e95312d..28a352c3e43fa57 100644 --- a/files/en-us/mozilla/add-ons/webextensions/api/permissions/request/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/api/permissions/request/index.md @@ -6,20 +6,19 @@ browser-compat: webextensions.api.permissions.request sidebar: addonsidebar --- -Asks the user for the permissions listed in the {{WebExtAPIRef("permissions.Permissions")}} object. +Asks the user for the permissions listed in a {{WebExtAPIRef("permissions.Permissions")}} object. -The `Permissions` argument can contain an `origins` property, an array of [host permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#host_permissions), a `permissions` property, an array of [API permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#api_permissions), or both. +The permissions requested must be listed in the extension's: -Requested permissions must be defined in the [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) manifest.json key. The `origins` property can include permissions matching a subset of the hosts matched by an optional permission. For example, if `optional_permissions` include `"*://mozilla.org/"`, then `permissions.origins` can include `"https://developer.mozilla.org/"`. +- [`optional_permissions`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions) key of its manifest.json file for `origins` and `permissions`. The `origins` property can include permissions matching a subset of the hosts matched by an optional permission. For example, if `optional_permissions` include `"*://mozilla.org/"`, then `permissions.origins` can include `"https://developer.mozilla.org/"`. +- [`gecko.data_collection_permissions.optional`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/browser_specific_settings#optional) property of the `browser_specific_settings` key of its manifest.json file for `data_collection`. Requests for [optional-only permissions](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/optional_permissions#optional-only_permissions) can't include any other optional permissions. -The request can only be made inside the handler for a [user action](/en-US/docs/Mozilla/Add-ons/WebExtensions/User_actions). Unless all the permissions requested are ones granted silently, the browser asks the user whether to grant the requested permissions. One request is made for all requested permissions: either all permissions are granted or none are. +The extension can only make the request inside the handler for a [user action](/en-US/docs/Mozilla/Add-ons/WebExtensions/User_actions). Unless the browser can grant all the requested permissions silently, it prompts the user to grant them. The browser makes one request for all requested permissions: either all are granted, or none are. The extension retains any permissions granted, even over upgrade and disable and enable cycling. -This is an asynchronous function that returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). - ## Syntax ```js-nolint @@ -35,11 +34,11 @@ let requesting = browser.permissions.request( ### Return value -A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that is fulfilled with `true` if the extension is granted the permissions listed in the `permissions` argument, or `false` otherwise. +A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with `true` if the browser grants the extension the permissions listed in the `permissions` argument, or `false` otherwise. ## Examples -This code adds a click handler that asks for various permissions, then logs the result of the request and the extension's permissions after the request completes. +This code adds a click handler that prompts the user for various permissions, then logs the request's outcome and the extension's permissions after the request completes. ```js const permissionsToRequest = { diff --git a/files/en-us/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.md b/files/en-us/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.md index 8e90be32817f500..b12a86c6a8159da 100644 --- a/files/en-us/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.md +++ b/files/en-us/mozilla/add-ons/webextensions/manifest.json/browser_specific_settings/index.md @@ -55,7 +55,7 @@ The `browser_specific_settings` key contains keys that are specific to a particu Firefox stores browser-specific settings in these properties: -- `gecko` for the desktop version of Firefox. +- `gecko` for the desktop and (when enabled) Android versions of Firefox. - `gecko_android` for the Android version of Firefox. The `gecko` sub-key supports these properties: