1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

Catch possible exceptions when accessing window.localStorage

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/899

This is a code review of previous commits related to
the above issue.
This commit is contained in:
Raymond Hill 2020-03-03 11:31:14 -05:00
parent 39dc88b8f5
commit 08d370d32e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -246,6 +246,7 @@ vAPI.localStorage = {
this.cache = new Promise(resolve => {
browser.storage.local.get('localStorage', bin => {
this.cache = undefined;
try {
if (
bin instanceof Object === false ||
bin.localStorage instanceof Object === false
@ -256,13 +257,11 @@ vAPI.localStorage = {
const key = ls.key(i);
this.cache[key] = ls.getItem(key);
}
//ls.clear();
browser.storage.local.set({ localStorage: this.cache });
} else {
try {
this.cache = bin.localStorage;
} catch(ex) {
}
} catch(ex) {
}
if ( this.cache instanceof Object === false ) {
this.cache = {};