-
Notifications
You must be signed in to change notification settings - Fork 23.2k
Bug 2044712 methods to get contextual identities icons and colors #44372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| title: contextualIdentities.getSupportedColors() | ||
| slug: Mozilla/Add-ons/WebExtensions/API/contextualIdentities/getSupportedColors | ||
| page-type: webextension-api-function | ||
| browser-compat: webextensions.api.contextualIdentities.getSupportedColors | ||
| sidebar: addonsidebar | ||
| --- | ||
|
|
||
| Returns the colors supported by the browser for contextual identities. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```js-nolint | ||
| let colors = browser.contextualIdentities.getSupportedColors() | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| None. | ||
|
|
||
| ### Return value | ||
|
|
||
| A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with an array of objects, one for each supported color. Each object has these properties: | ||
|
|
||
| - `color` | ||
| - : `string`. The name of the color (for example, `"blue"`). This is the value used in the `color` property of {{WebExtAPIRef("contextualIdentities.ContextualIdentity")}}. | ||
| - `colorCode` | ||
| - : `string`. A hex code for the color (for example, `"#37adff"`). | ||
|
|
||
| If the contextual identities feature is not enabled, the promise is rejected with an error message. | ||
|
|
||
| ## Examples | ||
|
|
||
| Retrieve all supported colors and log their names and hex codes: | ||
|
|
||
| ```js | ||
| function onGot(colors) { | ||
| for (const { color, colorCode } of colors) { | ||
| console.log(`${color}: ${colorCode}`); | ||
| } | ||
| } | ||
|
|
||
| function onError(error) { | ||
| console.error(error); | ||
| } | ||
|
|
||
| browser.contextualIdentities.getSupportedColors().then(onGot, onError); | ||
| ``` | ||
|
|
||
| {{WebExtExamples}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| title: contextualIdentities.getSupportedIcons() | ||
| slug: Mozilla/Add-ons/WebExtensions/API/contextualIdentities/getSupportedIcons | ||
| page-type: webextension-api-function | ||
| browser-compat: webextensions.api.contextualIdentities.getSupportedIcons | ||
| sidebar: addonsidebar | ||
| --- | ||
|
|
||
| Returns the icons supported by the browser for contextual identities. | ||
|
|
||
| ## Syntax | ||
|
|
||
| ```js-nolint | ||
| let icons = browser.contextualIdentities.getSupportedIcons() | ||
| ``` | ||
|
|
||
| ### Parameters | ||
|
|
||
| None. | ||
|
|
||
| ### Return value | ||
|
|
||
| A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with an array of objects, one for each supported icon. Each object has these properties: | ||
|
|
||
| - `icon` | ||
| - : `string`. The name of the icon (for example, `"fingerprint"`). This is the value used in the `icon` property of {{WebExtAPIRef("contextualIdentities.ContextualIdentity")}}. | ||
| - `iconUrl` | ||
| - : `string`. A `resource://` URL pointing to the icon's SVG file (for example, `"resource://usercontext-content/fingerprint.svg"`). | ||
|
|
||
| If the contextual identities feature is not enabled, the promise is rejected with an error message. | ||
|
|
||
| ## Examples | ||
|
|
||
| Retrieve all supported icons and log their names and URLs: | ||
|
|
||
| ```js | ||
| function onGot(icons) { | ||
| for (const { icon, iconUrl } of icons) { | ||
| console.log(`${icon}: ${iconUrl}`); | ||
| } | ||
| } | ||
|
|
||
| function onError(error) { | ||
| console.error(error); | ||
| } | ||
|
|
||
| browser.contextualIdentities.getSupportedIcons().then(onGot, onError); | ||
| ``` | ||
|
|
||
| {{WebExtExamples}} | ||
|
|
||
| ## Browser compatibility | ||
|
|
||
| {{Compat}} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,12 +72,13 @@ Firefox 153 is the current [Nightly version of Firefox](https://www.firefox.com/ | |
|
|
||
| ## Changes for add-on developers | ||
|
|
||
| - Adds the {{WebExtAPIRef("contextualIdentities.getSupportedColors()")}} and {{WebExtAPIRef("contextualIdentities.getSupportedIcons()")}} methods to retrieve the colors and icons available for contextual identities (containers). ([Firefox bug 2044712](https://bugzil.la/2044712)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: could you move this change after the adoptedStyleSheets change? We don't really have a convention for the order, but this change to contextualIdentities is quite niche. I also anticipate another release note for more colors, which would thematically fit with this new API as well: https://bugzilla.mozilla.org/show_bug.cgi?id=2044354#c5 |
||
| - Extension content scripts can now read and modify constructed stylesheets in {{domxref("document.adoptedStyleSheets")}} and {{domxref("ShadowRoot.adoptedStyleSheets")}}, without `.wrappedJSObject`. ([Firefox bug 1751346](https://bugzil.la/1751346)) | ||
|
|
||
| <!-- ### Removals --> | ||
|
|
||
| <!-- ### Other --> | ||
|
|
||
| - Extension content scripts can now read and modify constructed stylesheets in {{domxref("document.adoptedStyleSheets")}} and {{domxref("ShadowRoot.adoptedStyleSheets")}}, without `.wrappedJSObject`. ([Firefox bug 1751346](https://bugzil.la/1751346)) | ||
|
|
||
| ## Experimental web features | ||
|
|
||
| These features are shipping in Firefox 153 but are disabled by default. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: rejecting with anel error is not what the implementation does right now, but I'll make sure that it behaves so before 153 ships to release.