Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note re exception from storage.managed.get #36586

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,14 @@ Where `<storageType>` is one of the storage types — {{WebExtAPIRef("storage.sy

### Return value

A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a `results` object, containing every object in `keys` that was found in the storage area. If `keys` is an object, keys that are not found in the storage area will have their values given by the `keys` object.
A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) that resolves to a `results` object, containing every object in `keys` found in the storage area. If `keys` is an object, keys that are not found in the storage area have their values given by the `keys` object.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

containing every object in keys found in the storage area.

The wording here seems a little off. The value associated with a given may be a primitive value rather than an object. Also, the structure of this sentence seems a little harder to parse than necessary. What do you think about this?

containing a key-value pair for every matching key found in the storage area.

rebloor marked this conversation as resolved.
Show resolved Hide resolved

If the operation failed, the promise is rejected with an error message.
If the operation fails, the promise is rejected with an error message.

If managed storage is not set, `undefined` will be returned.
If managed storage is not set, `undefined` is returned.

> [!WARNING]
> When used within a content script in Firefox versions prior to 52, the Promise returned by `browser.storage.local.get()` is fulfilled with an Array containing one Object. The Object in the Array contains the `keys` found in the storage area, as described above.
>
> The Promise is correctly fulfilled with an Object when used in the background context (background scripts, popups, options pages, etc.).
>
> When this API is used as `chrome.storage.local.get()`, it correctly passes an Object to the callback function.

## Browser compatibility

{{Compat}}
> In Firefox, if the managed storage manifest is missing, an exception is thrown when using this function to access managed storage (see [Firefox bug 1868153](https://bugzil.la/1868153)). This issue can be avoided by catching the error. This issue is related to the lack of support for the [`storage.managed_schema`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/storage) manifest key (see [Firefox bug 1771731](https://bugzil.la/1771731)). `storage.managed_schema` provides a fallback managed storage manifest definition on other browsers.
rebloor marked this conversation as resolved.
Show resolved Hide resolved

## Examples

Expand Down Expand Up @@ -145,5 +137,9 @@ let gettingItem = new Promise((resolve) =>
gettingItem.then(onGot); // -> Object { kitten: Object }
```

## Browser compatibility

{{Compat}}

> [!NOTE]
> This API is based on Chromium's [`chrome.storage`](https://developer.chrome.com/docs/extensions/reference/api/storage) API. This documentation is derived from [`storage.json`](https://chromium.googlesource.com/chromium/src/+/master/extensions/common/api/storage.json) in the Chromium code.