undefined value in StorageArea.set()
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 711
- Forks
- 95
- Avg merge
- 10d 11h
- Merged PRs (30d)
- 2
Description
Hi,
I noticed a difference between Firefox and Chromium on the StorageArea.set() method.
- In Firefox,
StorageArea.set()removes item when value isundefined. - In Chromium,
StorageArea.set()ignore item when value isundefined.
Expected
I propose a third solution where the value is saved in the storage.
This pseudo-code use assert.deepStrictEqual() from Node.js.
const data = { foo: undefined };
chrome.storage.local.set(data);
chrome.storage.local.get(Object.keys(data), (d) => assert.deepStrictEqual(d, data));
Testcase
- manifest.json:
{
"manifest_version": 2,
"name": "Test case",
"version": "1.0.0",
"background": {
"scripts": ["background.js"]
},
"permissions": ["storage"]
}
- background.js:
chrome.storage.local.clear(() => {
chrome.storage.local.set({ foo: "bar" });
chrome.storage.local.get("foo", (v) => console.log(v));
chrome.storage.local.set({ foo: undefined });
chrome.storage.local.get("foo", (v) => console.log(v));
chrome.storage.local.set({ foo: "baz" });
chrome.storage.local.get("foo", (v) => console.log(v));
});
Results
Firefox
{ foo: "bar" }
{ }
{ foo: "baz" }
Chromium
{ foo: "bar" }
{ foo: "bar" }
{ foo: "baz" }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the StorageArea.set() behavior described in the MDN link and compare the Firefox and Chromium results in the manifest.json/background.js testcase. Determine the agreed cross-browser behavior for undefined values, then document the decision in the relevant WebExtensions specification material; done means the behavior and expected result are unambiguous.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100