FF: when not dom.storage.enabled use dummies

This commit is contained in:
tophf 2017-08-28 13:29:56 +03:00
parent 777fc06834
commit cd6bcc6511
3 changed files with 11 additions and 5 deletions

View File

@ -18,7 +18,7 @@ var updater = {
ERROR_MD5: 'error: MD5 is invalid', ERROR_MD5: 'error: MD5 is invalid',
ERROR_JSON: 'error: JSON is invalid', ERROR_JSON: 'error: JSON is invalid',
lastUpdateTime: parseInt(tryCatch(() => localStorage.lastUpdateTime)) || Date.now(), lastUpdateTime: parseInt(localStorage.lastUpdateTime) || Date.now(),
checkAllStyles({observer = () => {}, save = true, ignoreDigest} = {}) { checkAllStyles({observer = () => {}, save = true, ignoreDigest} = {}) {
updater.resetInterval(); updater.resetInterval();

View File

@ -57,6 +57,13 @@ if (!BG || BG !== window) {
} }
} }
const FIREFOX_NO_DOM_STORAGE = FIREFOX && !tryCatch(() => localStorage);
if (FIREFOX_NO_DOM_STORAGE) {
// may be disabled via dom.storage.enabled
Object.defineProperty(window, 'localStorage', {value: {}});
Object.defineProperty(window, 'sessionStorage', {value: {}});
}
function notifyAllTabs(msg) { function notifyAllTabs(msg) {
const originalMessage = msg; const originalMessage = msg;

View File

@ -1,4 +1,4 @@
/* global prefs: true, contextMenus */ /* global prefs: true, contextMenus, FIREFOX_NO_DOM_STORAGE */
'use strict'; 'use strict';
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
@ -75,9 +75,6 @@ var prefs = new function Prefs() {
specific: new Map(), specific: new Map(),
}; };
// FF may think localStorage is a cookie or that it's not secure
const localStorage = tryCatch(() => window.localStorage) ? window.localStorage : {};
// coalesce multiple pref changes in broadcast // coalesce multiple pref changes in broadcast
let broadcastPrefs = {}; let broadcastPrefs = {};
@ -184,6 +181,8 @@ var prefs = new function Prefs() {
value = tryJSONparse(value) || defaultValue; value = tryJSONparse(value) || defaultValue;
break; break;
} }
} else if (FIREFOX_NO_DOM_STORAGE && BG) {
value = BG.localStorage[key] || defaultValue;
} else { } else {
value = defaultValue; value = defaultValue;
} }