Closed Bug 1758475 Opened 2 years ago Closed 2 years ago

Support StorageArea.onChanged (onChanged on storage.local/sync/managed)

Categories

(WebExtensions :: Storage, enhancement, P3)

enhancement

Tracking

(firefox101 fixed)

RESOLVED FIXED
101 Branch
Tracking Status
firefox101 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

Details

(Keywords: dev-doc-complete, Whiteboard: [addons-jira])

Attachments

(1 file)

The storage API has an onChanged event to allow the observation of storage changes.

Since Chrome 73, there is also an onChanged event on individual StorageArea methods, such as browser.storage.local.omChanged.

Motivations were given in more detail in this resolved feature request in Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=863277

And the lack of support has been reported as a documentation issue at https://github.com/mdn/content/issues/11411

As I wrote in that issue, storage.sync does support this now, so only local and managed are impacted.

Summary: Support StorageArea.onChanged (onChanged on storage.local/sync/managed) → Support StorageArea.onChanged (onChanged on storage.local/managed)

(In reply to Mark Hammond [:markh] [:mhammond] from comment #1)

As I wrote in that issue, storage.sync does support this now, so only local and managed are impacted.

I don't see a definition or implementation of storage.sync.onChanged.

There is storage.onChanged, but not an event on individual StorageArea objects:

  • storage.local.onChanged
  • storage.sync.onChanged
  • storage.managed.onChanged

storage.sync's API is defined at https://searchfox.org/mozilla-central/rev/61fcf20da23053d54f9a057e208dd5e7407a977c/toolkit/components/extensions/schemas/storage.json#159-287

storage.sync is implemented at https://searchfox.org/mozilla-central/rev/61fcf20da23053d54f9a057e208dd5e7407a977c/toolkit/components/extensions/child/ext-storage.js#281-296 and https://searchfox.org/mozilla-central/rev/61fcf20da23053d54f9a057e208dd5e7407a977c/toolkit/components/extensions/parent/ext-storage.js#145-166, but there is no onChanged event there.

That logic is hooked up with the storage.onChanged event at https://searchfox.org/mozilla-central/rev/b0779bcc485dc1c04334dfb9ea024cbfff7b961a/toolkit/components/extensions/parent/ext-storage.js#204

Note that StorageArea.onChanged and storage.onChanged are two different things. Although the implementation can use similar/shared logic, the interfaces exposed to extensions are distinct.

I'm going to refactor the storage event handler soon, so I may as well take this bug too.

Assignee: nobody → rob
Summary: Support StorageArea.onChanged (onChanged on storage.local/managed) → Support StorageArea.onChanged (onChanged on storage.local/sync/managed)
Whiteboard: [addons-jira]
Severity: -- → N/A
Priority: -- → P3
Depends on: 1748566

This will need documentation, plus a BCD entry. Support is Chrome 73+, Safari, Opera+Edge (both Chromium based), Firefox 101+.

Keywords: dev-doc-needed
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/ab8202d430a8
Add StorageArea.onChanged event targets r=rpl
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: