Firefox treats undefined object values as null on chrome.storage.sync.set
Categories
(WebExtensions :: Storage, defect)
Tracking
(firefox84 affected, firefox85 affected, firefox86 affected)
People
(Reporter: apple502j, Unassigned)
Details
Attachments
(1 file)
|
1.00 KB,
application/x-zip-compressed
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0
Steps to reproduce:
Attached a zip file of a demo extension. It has an option page with 4 buttons, 3 to call chrome.storage.sync.set with different values and 1 to call chrome.storage.sync.get. Press "hello" -> "undefined" -> "Get current value" to reproduce the bug.
Reproduction steps:
- On extension console/console on option page devtools, run
chrome.storage.sync.set({item: "hello"})to set the value - Repeat 1 except with undefined instead of
"hello" - Run
chrome.storage.sync.get(["item"], ({item}) => alert(value: ${item}))
Actual results:
On Google Chrome 87.0.4280.88 (official, 64bit) the alert says "value: hello", while on Firefox 84.0.1 it says "value: null", indicating that the second chrome.storage.sync.set call set the stored value to null instead of not changing.
Expected results:
It should follow Chrome's behavior.
chrome.storage expects values to be JSON serializable, so it makes sense that the behavior of the first argument of chrome.storage.sync.set is handled similar to JSON.stringify where keys whose value is undefined is omitted.
Comment 1•5 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 2•5 years ago
|
||
Hello,
I’ve managed to reproduce the issue based on the provided STR on the latest Nightly (86.0a1/20210103213448), Beta (85.0b4/20201220193140) and Release (84.0.1/20201221152838) under Windows 10 x64 and Ubuntu 16.04 LTS.
As mentioned in the original report, following the "hello" -> "undefined" > "Get current value" sequence will result in a "value: null" popup to be displayed.
Comment 3•5 years ago
|
||
This is working as intended. If you don't want to update a value, just omit the key from the object.
Description
•