aboutsummaryrefslogtreecommitdiff
path: root/main_background.js
diff options
context:
space:
mode:
authorhackademix <giorgio@maone.net>2019-01-28 15:49:13 +0100
committerhackademix <giorgio@maone.net>2019-01-28 15:49:13 +0100
commit5040061a3991d2159d9e0fc04237185686fcf189 (patch)
tree79107b246102a42bbc6f8fe8cf1176290ebee4a3 /main_background.js
parentc834adee1012322961d574e9212f8accd7b58414 (diff)
Gracefully degrade browser.sessions-based tab info cache on mobile.
Diffstat (limited to 'main_background.js')
-rw-r--r--main_background.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/main_background.js b/main_background.js
index 57017db..b62788a 100644
--- a/main_background.js
+++ b/main_background.js
@@ -214,7 +214,7 @@ async function updateReport(tabId, oldReport, updateUI = false){
}
}
activityReports[tabId] = newReport;
- browser.sessions.setTabValue(tabId, url, newReport);
+ if (browser.sessions) browser.sessions.setTabValue(tabId, url, newReport);
dbg_print(newReport);
if (updateUI && activeMessagePorts[tabId]) {
dbg_print(`[TABID: ${tabId}] Sending script blocking report directly to browser action.`);
@@ -290,7 +290,7 @@ async function addReportEntry(tabId, scriptHashOrUrl, action) {
}
}
- browser.sessions.setTabValue(tabId, report.url, report);
+ if (browser.sessions) browser.sessions.setTabValue(tabId, report.url, report);
updateBadge(tabId, report);
return entryType;
}
@@ -419,7 +419,8 @@ async function onTabUpdated(tabId, changedInfo, tab) {
let [url] = tab.url.split("#");
let report = activityReports[tabId];
if (!(report && report.url === url)) {
- let cache = await browser.sessions.getTabValue(tabId, url);
+ let cache = browser.sessions &&
+ await browser.sessions.getTabValue(tabId, url) || null;
// on session restore tabIds may change
if (cache && cache.tabId !== tabId) cache.tabId = tabId;
updateBadge(tabId, activityReports[tabId] = cache);