summaryrefslogtreecommitdiff
path: root/src/bg
diff options
context:
space:
mode:
authorhackademix2018-09-08 23:09:39 +0200
committerhackademix2018-09-08 23:09:39 +0200
commit4f7d8579afa3b6a71173b3deefaf359d63e1e4e9 (patch)
treeb45998ba15b49ebb5bcebfc6009e3df77c059403 /src/bg
parentb60cbbd49e6d452adeb3abf8cc47ca276000a4db (diff)
downloadnoscript-4f7d8579afa3b6a71173b3deefaf359d63e1e4e9.tar.gz
noscript-4f7d8579afa3b6a71173b3deefaf359d63e1e4e9.tar.xz
noscript-4f7d8579afa3b6a71173b3deefaf359d63e1e4e9.zip
More efficient window.name persistence for tab-scoped permissions.
Diffstat (limited to 'src/bg')
-rw-r--r--src/bg/ChildPolicies.js2
-rw-r--r--src/bg/RequestGuard.js4
-rw-r--r--src/bg/Settings.js6
3 files changed, 10 insertions, 2 deletions
diff --git a/src/bg/ChildPolicies.js b/src/bg/ChildPolicies.js
index 99402ca..e8608ad 100644
--- a/src/bg/ChildPolicies.js
+++ b/src/bg/ChildPolicies.js
@@ -102,7 +102,7 @@
let preamble = info ? `${marker} + ${JSON.stringify(JSON.stringify([info]))} + ${marker} + "," + ` : "";
await browser.tabs.executeScript(tabId, {
code: `window.name = ${preamble}window.name.split(${marker} + ",").pop();`,
- allFrames: false,
+ allFrames: true,
matchAboutBlank: true,
runAt: "document_start",
});
diff --git a/src/bg/RequestGuard.js b/src/bg/RequestGuard.js
index 299e1a3..8850542 100644
--- a/src/bg/RequestGuard.js
+++ b/src/bg/RequestGuard.js
@@ -317,6 +317,10 @@ var RequestGuard = (() => {
await ChildPolicies.update(policy);
}
capabilities = perms.capabilities;
+ } else {
+ if (!isMainFrame && type === "sub_frame") {
+ await Settings.enforceTabRestrictions(tabId);
+ }
}
if (isMainFrame && !TabStatus.map.has(tabId)) {
debug("No TabStatus data yet for noscriptFrame", tabId);
diff --git a/src/bg/Settings.js b/src/bg/Settings.js
index 56c88f4..a5fca55 100644
--- a/src/bg/Settings.js
+++ b/src/bg/Settings.js
@@ -90,7 +90,7 @@ var Settings = {
if (typeof unrestrictedTab === "boolean") {
ns.unrestrictedTabs[unrestrictedTab ? "add" : "delete"](tabId);
- ChildPolicies.storeTabInfo(tabId, unrestrictedTab && {unrestricted: true});
+ this.enforceTabRestrictions(tabId, unrestrictedTab);
}
if (reloadAffected) {
browser.tabs.reload(tabId);
@@ -123,4 +123,8 @@ var Settings = {
}, null, 2);
},
+ async enforceTabRestrictions(tabId, unrestricted = ns.unrestrictedTabs.has(tabId)) {
+ await ChildPolicies.storeTabInfo(tabId, unrestricted && {unrestricted: true});
+ return unrestricted;
+ }
}