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
await browser.storage.<storageType>.setAccessLevel( accessLevel // string )
<storageType> can be the storage.session storage type.
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
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
setAccessLevel |
96Only supported for the session storage area. |
96Only supported for the session storage area. |
No | ? | 82Only supported for the session storage area. |
No | ? | ? | No | ? | No | ? |
Note: This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/setAccessLevel