I'm building an extension for Microsoft Edge. I have an options page which saves some values to localStorage like that:
localStorage.setItem('xxx', document.getElementById("xxx").value);
And retrieves them in background script:
var value1 = localStorage.getItem('xxx');
Works perfectly fine in all browsers except for Edge. I have to close Edge, reopen it and only then it updates storage for background.html. I inspected options.html and background.html and found out that updating options storage won't affect background, which is strange because they have to share the same storage.
Is there some workaround for that issue?
So, I've found a solution which works for me. I use chrome.storage.local instead of localStorage and get real-time options-background communication.
I set some value in options.js:
chrome.storage.local.set({xxx:document.getElementById('xxx').value});
And create listener in background.js to track real-time changes:
chrome.storage.onChanged.addListener(function(changes, namespace) {
for(var key in changes) {
window[key] = changes[key].newValue;
}
});