summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--background.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/background.js b/background.js
index 0df541a..5295d9f 100644
--- a/background.js
+++ b/background.js
@@ -4,14 +4,17 @@ let certs = [];
// On header receive, inspect cert and update app icon as required
async function onHeaderReceive(details) {
+ if (details.tabId < 0) // tabId < 0 means non-user tab
+ return;
+
try {
- await certInspectUpdate(details.requestId);
+ await certInspectUpdate(details.requestId, details.tabId);
} catch(error) {
console.error(error);
}
}
-async function certInspectUpdate(requestId) {
+async function certInspectUpdate(requestId, tabId) {
let securityInfo = await browser.webRequest.getSecurityInfo(
requestId,
{
@@ -20,7 +23,7 @@ async function certInspectUpdate(requestId) {
);
if (securityInfo.state !== "secure" || securityInfo.isUntrusted) {
- setIcon("nope");
+ setIcon("nope", tabId);
return;
}
@@ -31,16 +34,19 @@ async function certInspectUpdate(requestId) {
for (let cert of certs) {
if (rootCA.subject.includes(cert)) {
- setIcon("nope");
+ setIcon("nope", tabId);
return;
}
}
- setIcon("ok");
+ setIcon("ok", tabId);
}
-function setIcon(icon) {
- browser.browserAction.setIcon({ path: "icons/" + icon + ".png" });
+function setIcon(icon, tabId) {
+ browser.browserAction.setIcon({
+ path: "icons/" + icon + ".png",
+ tabId: tabId
+ });
}
// Listen for all header receive events, which contain the cert details we want