Fixed issue #35 "tabId is not defined" on startup.

This commit is contained in:
hackademix 2018-11-12 02:18:58 +01:00
parent 6860ee2a40
commit 24f738337b
1 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ function deferWebTraffic(promiseToWaitFor, next) {
let seen = seenTabs.has(nav.tabId); let seen = seenTabs.has(nav.tabId);
debug(`%s navigation %o`, seen ? "seen" : "unseen", nav); debug(`%s navigation %o`, seen ? "seen" : "unseen", nav);
if (!seen) { if (!seen) {
reloadTab(tabId); reloadTab(nav.tabId);
} }
} }
} }
@ -23,7 +23,7 @@ function deferWebTraffic(promiseToWaitFor, next) {
error(e, "Can't reload tab", tabId); error(e, "Can't reload tab", tabId);
} }
} }
async function waitFor(request) { async function waitFor(request) {
let {type, documentUrl, url, tabId, frameId} = request; let {type, documentUrl, url, tabId, frameId} = request;
if (tabId === browser.tabs.TAB_ID_NONE) return; if (tabId === browser.tabs.TAB_ID_NONE) return;
@ -45,9 +45,9 @@ function deferWebTraffic(promiseToWaitFor, next) {
} }
debug("Green light to %s %s from %s", type, url, documentUrl); debug("Green light to %s %s from %s", type, url, documentUrl);
} }
function spyTabs(request) { function spyTabs(request) {
debug("Spying request %o", request); debug("Spying request %o", request);
} }
browser.webRequest.onHeadersReceived.addListener(spyTabs, { browser.webRequest.onHeadersReceived.addListener(spyTabs, {
@ -57,7 +57,7 @@ function deferWebTraffic(promiseToWaitFor, next) {
browser.webRequest.onBeforeRequest.addListener(waitFor, { browser.webRequest.onBeforeRequest.addListener(waitFor, {
urls: ["<all_urls>"] urls: ["<all_urls>"]
}, ["blocking"]); }, ["blocking"]);
(async () => { (async () => {
await promiseToWaitFor; await promiseToWaitFor;
browser.webNavigation.onCommitted.removeListener(checkNavigation); browser.webNavigation.onCommitted.removeListener(checkNavigation);
@ -65,4 +65,4 @@ function deferWebTraffic(promiseToWaitFor, next) {
browser.webRequest.onHeadersReceived.removeListener(spyTabs); browser.webRequest.onHeadersReceived.removeListener(spyTabs);
if (next) next(); if (next) next();
})(); })();
} }