Closed Bug 1684610 Opened 5 years ago Closed 5 years ago

Firefox treats undefined object values as null on chrome.storage.sync.set

Categories

(WebExtensions :: Storage, defect)

Firefox 84
defect

Tracking

(firefox84 affected, firefox85 affected, firefox86 affected)

RESOLVED DUPLICATE of bug 1499842
Tracking Status
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.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Storage
Product: Firefox → WebExtensions

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.

Status: UNCONFIRMED → NEW
Ever confirmed: true

This is working as intended. If you don't want to update a value, just omit the key from the object.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: