Record document origins in TabStatus.

This commit is contained in:
hackademix 2020-01-08 13:54:01 +01:00
parent bd5acb2be3
commit ae8317da00
1 changed files with 9 additions and 9 deletions

View File

@ -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));