I would expect when I await
setting new value to the storage, all onChanged
listeners has fired. But it doesn’t work in Firefox, but it seems to work in Chrome.
Is this a bug?
Example code (can be executed on any add-on page console):
(async () => {
let text = '...';
browser.storage.onChanged.addListener(onStorageChange);
console.log('EXPERIMENT: before', text);
// we await setting new value - this will trigger "onChanged" handler and mutate "text"
await browser.storage.local.set({experiment: Date.now()});
// text value should be changed now
console.log('EXPERIMENT: after', text);
browser.storage.onChanged.removeListener(onStorageChange);
function onStorageChange(changes) {
text = 'text mutated!!!';
console.log('EXPERIMENT: onChanged', text);
}
})();
EDIT:
It works in ESR 60, but not in 66, 67, 68, 69. So it does sounds like a bug…
EDIT 2:
I’ve reported a bug.