diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index 564355c..1ccab69 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -589,7 +589,7 @@ var RequestGuard = (() => { if (pending && pending.redirected && pending.redirected.url === request.url) { return lanRes; // don't go on stripping cookies if we're in a redirection loop } - let chainNext = r => r === ABORT ? r : TabGuard.check(request); + let chainNext = r => r === ABORT ? r : TabGuard.onSend(request); return lanRes instanceof Promise ? lanRes.then(chainNext) : chainNext(lanRes); }, @@ -688,7 +688,7 @@ var RequestGuard = (() => { let {requestId, url, tabId, frameId, type} = request; if (type === "main_frame") { TabStatus.initTab(tabId); - TabGuard.postCheck(request); + TabGuard.onCleanup(request); } let scriptBlocked = request.responseHeaders.some( h => csp.isMine(h) && csp.blocks(h.value, "script") @@ -721,11 +721,11 @@ var RequestGuard = (() => { } } } - TabGuard.postCheck(request); + TabGuard.onCleanup(request); }, onErrorOccurred(request) { pendingRequests.delete(request.requestId); - TabGuard.postCheck(request); + TabGuard.onCleanup(request); } }; function fakeRequestFromCSP(report, request) { diff --git a/src/bg/TabGuard.js b/src/bg/TabGuard.js index 0b6d98a..fa42a17 100644 --- a/src/bg/TabGuard.js +++ b/src/bg/TabGuard.js @@ -27,6 +27,8 @@ var TabGuard = (() => { anonymizedTabs.delete(tab.id); }); + const anonymizedRequests = new Set(); + let allowedGroups, filteredGroups; let forget = () => { allowedGroups = {}; @@ -53,10 +55,12 @@ var TabGuard = (() => { return { forget, - check(request) { + onSend(request) { const mode = ns.sync.TabGuardMode; if (mode === "off" || !request.incognito && mode!== "global") return; + anonymizedRequests.delete(request.id); + const {tabId, type, url, originUrl} = request; if (tabId < 0) return; // no tab, no party @@ -160,6 +164,7 @@ var TabGuard = (() => { requestHeaders = requestHeaders.filter(h => !AUTH_HEADERS_RX.test(h.name)); debug("[TabGuard] Removing auth headers from %o (%o)", request, requestHeaders); anonymizedTabs.set(tabId, {tabDomain, otherDomains: [...otherDomains]}); + anonymizedRequests.add(request.id); return {requestHeaders}; }; @@ -195,12 +200,16 @@ var TabGuard = (() => { return mustFilter ? filterAuth() : null; })(); }, - postCheck(request) { + onCleanup(request) { let {requestId, tabId} = request; if (scheduledCuts.has(requestId)) { scheduledCuts.delete(requestId); TabTies.cut(tabId); } + anonymizedRequests.delete(request.id); + }, + isAnonymizedRequest(requestId) { + return anonymizedRequests.has(requestId); }, isAnonymizedTab(tabId) { return anonymizedTabs.has(tabId);