From 99e8c8b09f7270d335985fb84fa237323dfe2242 Mon Sep 17 00:00:00 2001 From: hackademix Date: Wed, 1 Aug 2018 19:00:33 +0200 Subject: Skip non-content windows when deferring startup page loading. --- src/bg/deferWebTraffic.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bg/deferWebTraffic.js b/src/bg/deferWebTraffic.js index 6efef97..fced870 100644 --- a/src/bg/deferWebTraffic.js +++ b/src/bg/deferWebTraffic.js @@ -2,7 +2,7 @@ function deferWebTraffic(promiseToWaitFor, next) { debug("deferWebTraffic on %o", promiseToWaitFor); let seenTabs = new Set(); function checkNavigation(nav) { - if (nav.url.startsWith("http")) { + if (nav.tabId !== browser.tabs.TAB_ID_NONE && nav.url.startsWith("http")) { let seen = seenTabs.has(nav.tabId); debug(`%s navigation %o`, seen ? "seen" : "unseen", nav); if (!seen) { @@ -14,7 +14,6 @@ function deferWebTraffic(promiseToWaitFor, next) { function reloadTab(tabId) { seenTabs.add(tabId); try { - // browser.tabs.update(tabId, {url: documentUrl}); browser.tabs.executeScript(tabId, { runAt: "document_start", code: "window.location.reload(false)" @@ -27,6 +26,7 @@ function deferWebTraffic(promiseToWaitFor, next) { async function waitFor(request) { let {type, documentUrl, url, tabId, frameId} = request; + if (tabId === browser.tabs.TAB_ID_NONE) return; if (!seenTabs.has(tabId)) { if (type === "main_frame") { seenTabs.add(tabId); @@ -47,9 +47,9 @@ function deferWebTraffic(promiseToWaitFor, next) { } function spyTabs(request) { - debug("Spying request %o", request); - + debug("Spying request %o", request); } + browser.webRequest.onHeadersReceived.addListener(spyTabs, { urls: [""], types: ["main_frame"], -- cgit v1.2.3