Where/how can I check what I actually wrote to local storage while testing a temporary extension?
I’m struggling with saving the addon’s options, and want to see what was written to storage.
If I look at config:about, the data doesn’t seem to correlate with what my addon is writing/reading, so I guess the values are stored elsewhere (at least for temporary addons)?
You have to use the best debugging techniques known to man:
browser.storage.local.get({}).then(console.log)
- Interact with it in the Add-on devtools console
- Interact with it in the Add-on devtools debugger
What you can’t do, however is use the “Storage” tool in the Add-on devtools. That does not list items stored with browser.storage.local.set
. (It does however show data in the window.localStorage
which is a different storage mechanism)
Hello, I try this, but I can’t see data in devtools.
browser.storage.local.get('type-trad').then(function(item){
if (item.typeTrad === undefined || item.typeTrad === '0') {
document.querySelector('#type-none').checked = true;
} else if (item.typeTrad === '1') {
document.querySelector('#type-together').checked = true;
} else if (item.typeTrad === '2') {
document.querySelector('#type-split').checked = true;
}
});
var typeTrad_options = document.querySelectorAll('#type-none, #type-together, #type-split');
for (i = 0; i < typeTrad_options.length; i++) {
typeTrad_options[i].onchange = function(e) {
browser.storage.local.set({ typeTrad: this.value });
}
}
It’s not very simple to debug storage with about:debugging…