Fixed bug in policy fetching.

This commit is contained in:
hackademix 2019-10-31 23:52:54 +01:00
parent 25fd1727b6
commit 08a41b3a62
2 changed files with 19 additions and 5 deletions

View File

@ -142,7 +142,8 @@
async fetchChildPolicy({url, contextUrl}, sender) {
await ns.initializing;
return (this.fetchChildPolicy = this.fetchChildPolicySync)(...arguments);
return (messageHandler.fetchChildPolicy =
messageHandler.fetchChildPolicySync)(...arguments);
},
fetchChildPolicySync({url, contextUrl}, sender) {
let {tab, frameId} = sender;

View File

@ -35,14 +35,27 @@
fetchPolicy() {
let url = document.URL;
if (url.startsWith("http")) {
debug(`Fetching policy from document %s, readyState %s, content %s`,
url, document.readyState, document.documentElement.outerHTML);
if (!/^(?:file|ftp|https?):/i.test(url)) {
(async () => {
this.setup(await Messages.send("fetchChildPolicy", {url, contextUrl: url}));
let policy;
try {
policy = await Messages.send("fetchChildPolicy", {url, contextUrl: url});
} catch (e) {
console.error("Error while fetching policy", e);
}
if (policy === undefined) {
log("Policy was undefined, retrying in 1/2 sec...");
setTimeout(() => this.fetchPolicy(), 500);
return;
}
this.setup(policy);
})();
return;
}
debug(`Fetching policy from document %s, readyState %s, content %s`,
url, document.readyState, document.documentElement.outerHTML);
let originalState = document.readyState;
let blockedScripts = [];