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

webExtension Storage API, StorageArea.set(), note about browser differences #20222

Closed
carlosjeurissen opened this issue Sep 1, 2022 · 3 comments
Labels
Content:WebExt WebExtensions docs

Comments

@carlosjeurissen
Copy link
Contributor

MDN URL

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/storage/StorageArea/set

What specific section or headline is this issue about?

Syntax > Parameters > keys

What information was incorrect, unhelpful, or incomplete?

As mentioned here:
w3c/webextensions#263

Setting a value to undefined has inconsistent behaviour across browsers.

What did you expect to see?

Have a warning noting the difference between the behaviour of setting a value to undefined.

In Firefox, setting a value to undefined will actually set it to undefined, while in other browsers, setting something to undefined is simply ignored and the original value is kept.

Do you have any supporting links, references, or citations?

As mentioned here:
w3c/webextensions#263

In there, @Rob--W mentioned the relevant bug reports:

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@github-actions github-actions bot added Content:WebExt WebExtensions docs needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Sep 1, 2022
@Rob--W
Copy link
Member

Rob--W commented Sep 1, 2022

Let's wait at least a week so that we can decide on the Firefox side how to address this inconsistency. If we decide to fix this, then the documentation update can be part of the bug resolution.

@sideshowbarker sideshowbarker removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Sep 3, 2022
@Rob--W
Copy link
Member

Rob--W commented Sep 5, 2022

We triaged the bug at https://bugzilla.mozilla.org/show_bug.cgi?id=1499842 and decided that we'd like to change the behavior to match Chrome and Safari.

Regardless of the fix, the documentation should be updated as follows:

  • The recommendation for removing values is to use storageArea.remove
  • The recommendation for overwriting values with a void value is to use null (not undefined)
  • The behavior of calling storageArea.set({keyname: undefined}) is inconsistent across browsers. Chrome and Safari do NOT change the value of keyname, while Firefox currently overwrites keyname with undefined (or sometimes null, e.g. in the storage.sync API). The recommendation is to NOT use undefined as a value, but use one of the other two options for consistent behavior.

@rebloor
Copy link
Contributor

rebloor commented Nov 10, 2023

Fixed by #30101

@rebloor rebloor closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebExt WebExtensions docs
Projects
None yet
Development

No branches or pull requests

4 participants