StorageArea.setAccessLevel()
Sets the access level for the storage area.
Use this method to:
- Expose the
sessionstorage area to content scripts. Unlike other storage areas, by default,storage.sessionis only available to privileged (trusted) extension contexts by default. - Restrict content scripts' access to
local,managed, andsyncstorage areas. By default, these storage areas are exposed to all extension contexts, including content scripts.
Syntax
js
await browser.storage.<storageType>.setAccessLevel(
accessLevel // string
)
Where <storageType> is any of the storage types: storage.local, storage.managed, storage.session, or storage.sync.
Parameters
accessLevel-
String. The access level of the storage area. Possible values areTRUSTED_CONTEXTSorTRUSTED_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
Note:
This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.