From ae8317da006bf21bd5046fe6f782c9b2d5b131d4 Mon Sep 17 00:00:00 2001 From: hackademix Date: Wed, 8 Jan 2020 13:54:01 +0100 Subject: Record document origins in TabStatus. --- src/bg/RequestGuard.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js index 2f5a615..b3c8956 100644 --- a/src/bg/RequestGuard.js +++ b/src/bg/RequestGuard.js @@ -33,8 +33,13 @@ var RequestGuard = (() => { allowed: {}, blocked: {}, noscriptFrames: {}, + origins: new Set(), } }, + hasOrigin(tabId, origin) { + let records = this.map.get(tabId); + return records && records.origins.has(origin); + }, initTab(tabId, records = this.newRecords()) { if (tabId < 0) return; this.map.set(tabId, records); @@ -45,12 +50,7 @@ var RequestGuard = (() => { let policyType = policyTypesMap[type] || type; let requestKey = Policy.requestKey(url, policyType, documentUrl); let map = this.map; - let records; - if (map.has(tabId)) { - records = map.get(tabId); - } else { - records = this.initTab(tabId); - } + let records = map.has(tabId) ? map.get(tabId) : this.initTab(tabId); if (what === "noscriptFrame" && type !== "object") { let nsf = records.noscriptFrames; nsf[frameId] = optValue; @@ -60,6 +60,9 @@ var RequestGuard = (() => { Content.reportTo(request, optValue, type); } } + if (type.endsWith("frame")) { + records.origins.add(Sites.origin(url)); + } let collection = records[what]; if (collection) { if (type in collection) { @@ -125,9 +128,6 @@ var RequestGuard = (() => { : _("NotEnforced")}` }); }, - totalize(sum, value) { - return sum + value; - }, async probe(tabId) { if (tabId === undefined) { (await browser.tabs.query({})).forEach(tab => TabStatus.probe(tab.id)); -- cgit v1.2.3