Work with contextual identities: list, create, remove, and update contextual identities.
"Contextual identities" are a browser feature which addresses the idea that users assume multiple identities when browsing the web, and wish to maintain some separation between these identities. For example, a user might consider their "work identity" separate from their "personal identity", and not want to share cookies between these two contexts.
With the contextual identities feature, each contextual identity has a name, a color, and an icon. New tabs can be assigned to an identity, and the name, icon, and color will appear in the address bar. Internally, each identity gets its own cookie store which is not shared with other tabs.
Contextual identities are an experimental feature in Firefox and are only enabled by default in Firefox Nightly. To enable them in other versions of Firefox, set the privacy.userContext.enabled
preference to true. Note that although contextual identities are available in Firefox for Android, there's no UI to work with them in this version of the browser. This WebExtension API is only available if contextual identities are themselves enabled. For more information about contextual identities in Firefox, see this guide.
Contextual identities are not currently supported in any other browsers.
To use this API you need to include the "contextualIdentities" permission in your manifest.json file.
Types
contextualIdentities.ContextualIdentity
- Contains information about a contextual identity.
Functions
contextualIdentities.create()
- Creates a new contextual identity.
contextualIdentities.get()
- Retrieves a single contextual identity, given its cookie store ID.
contextualIdentities.query()
- Retrieves all contextual identities, or all contextual identities with a particular name.
contextualIdentities.update()
- Updates properties of an existing contextual identity.
contextualIdentities.remove()
- Deletes a contextual identity.
Browser compatibility
Chrome | Edge | Firefox | Firefox for Android | Opera | |
---|---|---|---|---|---|
ContextualIdentity | No | No | 53 | 53 | No |
create | No | No | 53 | 53 | No |
get | No | No | 53 | 53 | No |
query | No | No | 53 | 53 | No |
remove | No | No | 53 | 53 | No |
update | No | No | 53 | 53 | No |
The "Chrome incompatibilities" section is included from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities using the WebExtChromeCompat macro.
If you need to update this content, edit https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities, then shift-refresh this page to see your changes.