StorageArea.setAccessLevel()

Sets the access level for the storage area.

This method is only supported for the storage.session StorageArea.

Unlike other storage areas, storage.session is only available to privileged (trusted) extension contexts. This setAccessLevel method is used to expose the session storage area to content scripts too. By default, all other storage areas are exposed to all extension contexts, including content scripts.

This is an asynchronous function that returns a Promise.

Syntax

js
await browser.storage.<storageType>.setAccessLevel(
  accessLevel             // string
)

Where <storageType> is the storage.session storage type.

Parameters

accessLevel

String. The access level of the storage area. Possible values are TRUSTED_CONTEXTS or TRUSTED_AND_UNTRUSTED_CONTEXTS.

Return value

A Promise that is fulfilled with no arguments if the operation succeeded. If the operation failed, the promise is rejected with an error message.

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
setAccessLevel

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

Note: This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.