Support StorageArea.onChanged (onChanged on storage.local/sync/managed)
Categories
(WebExtensions :: Storage, enhancement, P3)
Tracking
(firefox101 fixed)
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
Comment 1•3 years ago
|
||
As I wrote in that issue, storage.sync does support this now, so only local
and managed
are impacted.
Assignee | ||
Comment 2•3 years ago
|
||
(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
andmanaged
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.
Comment 3•3 years ago
|
||
It's implemented at https://searchfox.org/mozilla-central/rev/b0779bcc485dc1c04334dfb9ea024cbfff7b961a/toolkit/components/extensions/ExtensionStorageSync.jsm#72-80 and https://searchfox.org/mozilla-central/rev/b0779bcc485dc1c04334dfb9ea024cbfff7b961a/toolkit/components/extensions/ExtensionStorageSync.jsm#161-183 - but maybe that's not hooked up for extension to actually use?
Assignee | ||
Comment 4•3 years ago
|
||
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.
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 5•3 years ago
•
|
||
This will need documentation, plus a BCD entry. Support is Chrome 73+, Safari, Opera+Edge (both Chromium based), Firefox 101+.
Assignee | ||
Comment 6•3 years ago
|
||
Comment 8•3 years ago
|
||
bugherder |
Updated•3 years ago
|
Comment 9•3 years ago
|
||
Documentation addressed in Support for StorageArea.onChanged and Session #16450 (BCD) and https://github.com/mdn/content/pull/16873 (docs)
Description
•