w3c / webextensions

Charter and administrivia for the WebExtensions Community Group (WECG)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency: storage onChanged

erosman opened this issue · comments

Inconsistency: storage onChanged

I have comes across an inconsistency in the return of the storage onChanged event.
(I am not aware of the return from other browsers.)

Example:

// same for browser and chrome APIs
browser.storage.onChanged.addListener()
browser.storage.sync.onChanged.addListener()

Firefox

  • Returns all values, changed or not
  • Event is dispatched regardless of the changed values

Chrome

  • Chrome returns only the changed values
  • Event is not dispatched if there are no changed values

See also:

This issue discusses the behavior of onChanged listener:

  • when set() an item, whether to compare its value has changed.
  • when remove() an item, whether to compare the item already removed.
  • when clear(), whether to compare the storage already empty.

In addition, what is the behavior of storage.sync when it syncs with the cloud (remote values)?

what is the behavior of storage.sync when it syncs with the cloud (remote values)

AFAIK the API considers the local copy (cache) to be fully representative of the remote state.

Adding consensus labels - everyone is in favor of only firing storage.onChanged when there are changes in values. Firefox is the only one that sometimes fires onChanged despite there not being any changes. This issue is tracked at https://bugzilla.mozilla.org/show_bug.cgi?id=1833153

The other discrepancy in the original issue was if the event should fire with all values in the storage area, or just the changed ones. Given the current behaviour in Chrome is to only include the changed values, I'm reluctant to look at changing that unless there are strong reasons to do so.