contextualIdentities.getSupportedIcons()

Returns the icons supported by the browser for contextual identities.

For Firefox 153 and later, use this method instead of hardcoding icon names in your extension. While the supported icons haven't changed since the introduction of contextual identities, using this method ensures your extension remains compatible with any changes.

These icon names are supported:

  • "briefcase"
  • "cart"
  • "chill"
  • "circle"
  • "dollar"
  • "fence"
  • "fingerprint"
  • "food"
  • "fruit"
  • "gift"
  • "pet"
  • "tree"
  • "vacation"

Syntax

js
let icons = browser.contextualIdentities.getSupportedIcons()

Parameters

None.

Return value

A 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 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);

Browser compatibility