diff options
author | hackademix | 2020-01-08 13:54:01 +0100 |
---|---|---|
committer | hackademix | 2020-01-08 13:54:01 +0100 |
commit | ae8317da006bf21bd5046fe6f782c9b2d5b131d4 (patch) | |
tree | 07007787ecf9f00e033be1cb483eb11dd6f72c41 /src/bg | |
parent | bd5acb2be3bac7cb22f8b2828b0f950af22b1f37 (diff) | |
download | noscript-ae8317da006bf21bd5046fe6f782c9b2d5b131d4.tar.gz noscript-ae8317da006bf21bd5046fe6f782c9b2d5b131d4.tar.xz noscript-ae8317da006bf21bd5046fe6f782c9b2d5b131d4.zip |
Record document origins in TabStatus.
Diffstat (limited to 'src/bg')
-rw-r--r-- | src/bg/RequestGuard.js | 18 |
1 files 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)); |