summaryrefslogtreecommitdiff
path: root/src/bg
diff options
context:
space:
mode:
authorhackademix2018-09-08 11:50:40 +0200
committerhackademix2018-09-08 11:50:40 +0200
commit7514aa20f959cd997e328cf8d15121d602a5c4fc (patch)
tree68e23c72ca9086b0f45b36a339dfb875a2cf65fe /src/bg
parent9edcf2f1f7f38c7cc933f467545a330391f70fbe (diff)
downloadnoscript-7514aa20f959cd997e328cf8d15121d602a5c4fc.tar.gz
noscript-7514aa20f959cd997e328cf8d15121d602a5c4fc.tar.xz
noscript-7514aa20f959cd997e328cf8d15121d602a5c4fc.zip
Saner message dispatching.
Diffstat (limited to 'src/bg')
-rw-r--r--src/bg/RequestGuard.js1
-rw-r--r--src/bg/main.js23
2 files changed, 13 insertions, 11 deletions
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js
index 947a7c1..e507806 100644
--- a/src/bg/RequestGuard.js
+++ b/src/bg/RequestGuard.js
@@ -394,6 +394,7 @@ var RequestGuard = (() => {
let blockedURI = report['blocked-uri'];
if (blockedURI && blockedURI !== 'self') {
let r = fakeRequestFromCSP(report, request);
+ if (r.url === 'inline') r.url = request.documentURI;
Content.reportTo(r, false, policyTypesMap[r.type]);
TabStatus.record(r, "blocked");
} else if (report["violated-directive"] === "script-src" && /; script-src 'none'/.test(report["original-policy"])) {
diff --git a/src/bg/main.js b/src/bg/main.js
index 9976f8f..376a981 100644
--- a/src/bg/main.js
+++ b/src/bg/main.js
@@ -24,7 +24,7 @@
async function init() {
await Defaults.init();
-
+
let policyData = (await Storage.get("sync", "policy")).policy;
if (policyData && policyData.DEFAULT) {
ns.policy = new Policy(policyData);
@@ -116,7 +116,7 @@
await Settings.update(settings);
toggleCtxMenuItem();
},
-
+
async broadcastSettings({
tabId = -1
}) {
@@ -140,12 +140,12 @@
async importSettings({data}) {
return await Settings.import(data);
},
-
+
async fetchChildPolicy({url, contextUrl}, sender) {
- return ChildPolicies.getForDocument(ns.policy,
+ return ChildPolicies.getForDocument(ns.policy,
url || sender.url, contextUrl || sender.tab.url);
},
-
+
async openStandalonePopup() {
let win = await browser.windows.getLastFocused();
let [tab] = (await browser.tabs.query({
@@ -184,10 +184,10 @@
if (this.running) return;
this.running = true;
- deferWebTraffic(init(),
+ deferWebTraffic(init(),
async () => {
Commands.install();
-
+
this.devMode = (await browser.management.getSelf()).installType === "development";
if (this.local.debug) {
if (this.devMode) {
@@ -231,16 +231,17 @@
},
async collectSeen(tabId) {
-
try {
let seen = Array.from(await Messages.send("collect", {}, {tabId, frameId: 0}));
debug("Collected seen", seen);
return seen;
} catch (e) {
- // probably a page where content scripts cannot run, let's open the options instead
- error(e, "Cannot collect noscript activity data");
+ await include("/lib/restricted.js");
+ if (!isRestrictedURL((await browser.tabs.get(tabId)).url)) {
+ // probably a page where content scripts cannot run, let's open the options instead
+ error(e, "Cannot collect noscript activity data");
+ }
}
-
return null;
},
};