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

Standardize storage.onChanged event when you set the same values. #86

Open
regseb opened this issue Sep 22, 2021 · 2 comments
Open

Standardize storage.onChanged event when you set the same values. #86

regseb opened this issue Sep 22, 2021 · 2 comments
Labels
inconsistency Inconsistent behavior across browsers

Comments

@regseb
Copy link

regseb commented Sep 22, 2021

Hi,

I noticed a difference between Firefox and Chromium on the storage.onChanged event. I don't know if this is the right place, but it might be nice to standardize this behavior. (Or maybe it's just a bug in Firefox or Chromium.)

  • In Firefox, the listeners of browser.storage.onChanged are fired when you set the same values.
  • In Chromium, the listeners are fired only if you set a different value.

testcase.zip:

  • manifest.json:
{
    "manifest_version": 2,
    "name": "Test case",
    "version": "1.0.0",
    "background": {
        "scripts": ["background.js"]
    },
    "permissions": ["storage"]
}
  • background.js:
chrome.storage.onChanged.addListener((changes) => {
    console.log(changes);
});
chrome.storage.local.clear(() => {
    chrome.storage.local.set({ foo: "bar" });
    chrome.storage.local.set({ foo: "bar" });
});
@Rob--W Rob--W added the inconsistency Inconsistent behavior across browsers label Sep 1, 2022
@carlosjeurissen
Copy link
Contributor

storage.onChanged indicates the value to actually have been changed. I do not see a use case in which it would be useful to also have the event fire when the value has not changed.

Removing the unneeded event firing seems like a potential performance improvement for Firefox and potentially other browsers.

@xeenon
Copy link
Collaborator

xeenon commented Oct 24, 2022

Safari also only fires onChanged if the value does change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inconsistency Inconsistent behavior across browsers
Projects
None yet
Development

No branches or pull requests

5 participants