diff options
author | hackademix | 2018-09-10 11:34:22 +0200 |
---|---|---|
committer | hackademix | 2018-09-10 11:34:22 +0200 |
commit | f88a6a6d6d16744b942970e9ba8a0ccd22e5c7b3 (patch) | |
tree | 11697b5856d074bfb507942a7fff2202be2588b2 | |
parent | 6414195445bebb2f6af896e2786302e820f0b263 (diff) | |
download | noscript-f88a6a6d6d16744b942970e9ba8a0ccd22e5c7b3.tar.gz noscript-f88a6a6d6d16744b942970e9ba8a0ccd22e5c7b3.tar.xz noscript-f88a6a6d6d16744b942970e9ba8a0ccd22e5c7b3.zip |
Streamlined child policy content scripts.
-rw-r--r-- | src/bg/ChildPolicies.js | 3 | ||||
-rw-r--r-- | src/content/content.js | 2 | ||||
-rw-r--r-- | src/content/dynamicNS.js | 4 | ||||
-rw-r--r-- | src/content/staticNS.js | 11 |
4 files changed, 9 insertions, 11 deletions
diff --git a/src/bg/ChildPolicies.js b/src/bg/ChildPolicies.js index ec08623..7f94ce0 100644 --- a/src/bg/ChildPolicies.js +++ b/src/bg/ChildPolicies.js @@ -176,8 +176,7 @@ getForDocument(policy, url, context = null) { return { - CURRENT: policy.get(url, context).perms.dry(), - DEFAULT: policy.DEFAULT.dry(), + permissions: policy.get(url, context).perms.dry(), MARKER: marker }; }, diff --git a/src/content/content.js b/src/content/content.js index b185f4f..fc76906 100644 --- a/src/content/content.js +++ b/src/content/content.js @@ -54,7 +54,7 @@ var notifyPage = async () => { debug(`No answer to fetchChildPolicy message. This should not be happening.`); return; } - ns.setup(childPolicy.CURRENT, childPolicy.MARKER); + ns.setup(childPolicy.permissions, childPolicy.MARKER); return; } diff --git a/src/content/dynamicNS.js b/src/content/dynamicNS.js index f865e8b..51a2701 100644 --- a/src/content/dynamicNS.js +++ b/src/content/dynamicNS.js @@ -7,8 +7,8 @@ if (!this.ns) { let deferredSetup = null; let nsStub = this.ns = { config: {}, - setup(CURRENT, MARKER) { - deferredSetup = [CURRENT, MARKER]; + setup(permissions, MARKER) { + deferredSetup = [permissions, MARKER]; }, merge: ns => { ns.config = Object.assign(ns.config, nsStub.config); diff --git a/src/content/staticNS.js b/src/content/staticNS.js index 5deb1ab..6179da0 100644 --- a/src/content/staticNS.js +++ b/src/content/staticNS.js @@ -33,9 +33,8 @@ backlog.add(eventName); }, - setup(DEFAULT, MARKER) { - this.config.DEFAULT = DEFAULT; - if(!this.config.CURRENT) this.config.CURRENT = DEFAULT; + setup(permissions, MARKER) { + this.config.permissions = permissions; // ugly hack: since now we use registerContentScript instead of the // filterRequest dynamic script injection hack, we use window.name @@ -70,13 +69,13 @@ }, window.wrappedJSObject) }); } - if (!this.config.DEFAULT || this.config.tabInfo.unrestricted) { + if (!this.config.permissions || this.config.tabInfo.unrestricted) { debug("%s is loading unrestricted by user's choice (%o).", document.URL, this.config); this.allows = () => true; this.capabilities = Object.assign( new Set(["script"]), { has() { return true; } }); } else { - let perms = this.config.CURRENT; + let perms = this.config.permissions; this.capabilities = new Set(perms.capabilities); new DocumentCSP(document).apply(this.capabilities, this.embeddingDocument); } @@ -84,7 +83,7 @@ this.canScript = this.allows("script"); this.fire("capabilities"); }, - config: { DEFAULT: null, CURRENT: null, tabInfo: {}, MARKER: "" }, + config: { permissions: null, tabInfo: {}, MARKER: "" }, allows(cap) { return this.capabilities && this.capabilities.has(cap); |