More reliable attempt to run onResponseHeader listener the last of installed extension.
This commit is contained in:
parent
3819592dfc
commit
bb232e0895
|
@ -462,19 +462,33 @@ var RequestGuard = (() => {
|
||||||
|
|
||||||
onResponseStarted(request) {
|
onResponseStarted(request) {
|
||||||
debug("onResponseStarted", request);
|
debug("onResponseStarted", request);
|
||||||
if (request.type === "main_frame") {
|
let {url, tabId, frameId, type} = request;
|
||||||
TabStatus.initTab(request.tabId);
|
if (type === "main_frame") {
|
||||||
|
TabStatus.initTab(tabId);
|
||||||
}
|
}
|
||||||
let scriptBlocked = request.responseHeaders.some(
|
let scriptBlocked = request.responseHeaders.some(
|
||||||
h => CSP.isMine(h) && CSP.blocks(h.value, "script")
|
h => CSP.isMine(h) && CSP.blocks(h.value, "script")
|
||||||
);
|
);
|
||||||
debug("%s scriptBlocked=%s setting noscriptFrame on ", request.url, scriptBlocked, request.tabId, request.frameId);
|
debug("%s scriptBlocked=%s setting noscriptFrame on ", url, scriptBlocked, tabId, frameId);
|
||||||
TabStatus.record(request, "noscriptFrame", scriptBlocked);
|
TabStatus.record(request, "noscriptFrame", scriptBlocked);
|
||||||
let pending = pendingRequests.get(request.requestId);
|
let pending = pendingRequests.get(request.requestId);
|
||||||
if (pending) {
|
if (pending) {
|
||||||
pending.scriptBlocked = scriptBlocked;
|
pending.scriptBlocked = scriptBlocked;
|
||||||
if (!pending.headersProcessed) {
|
if (!(pending.headersProcessed &&
|
||||||
debug("[WARNING] onHeadersReceived could not process", request);
|
(scriptBlocked || ns.policy.can(url, "script", request.documentURL))
|
||||||
|
)) {
|
||||||
|
debug("[WARNING] onHeadersReceived %s %o", frameId, tabId,
|
||||||
|
pending.headersProcessed ? "has been overridden on": "could not process",
|
||||||
|
request);
|
||||||
|
|
||||||
|
if (tabId !== -1) {
|
||||||
|
debug("[WARNING] Reloading %s frame %s of tab %s.", url, frameId, tabId);
|
||||||
|
browser.tabs.executeScript(tabId, {
|
||||||
|
runAt: "document_start",
|
||||||
|
code: "window.location.reload(false)",
|
||||||
|
frameId
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,11 +34,7 @@ function deferWebTraffic(promiseToWaitFor, next) {
|
||||||
if (frameId !== 0) {
|
if (frameId !== 0) {
|
||||||
documentUrl = request.frameAncestors.pop().url;
|
documentUrl = request.frameAncestors.pop().url;
|
||||||
}
|
}
|
||||||
if (tabId !== -1) {
|
reloadTab(tabId);
|
||||||
reloadTab(tabId);
|
|
||||||
} else {
|
|
||||||
debug("No tab to reload for %s %s from %s", type, url, documentUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug("Deferring %s %s from %s", type, url, documentUrl);
|
debug("Deferring %s %s from %s", type, url, documentUrl);
|
||||||
|
|
|
@ -19,12 +19,13 @@ class LastListener {
|
||||||
let ww = this._wrapped = [listener, listener].map(l => {
|
let ww = this._wrapped = [listener, listener].map(l => {
|
||||||
let w = (...args) => {
|
let w = (...args) => {
|
||||||
if (this.observed.hasListener(w._other)) {
|
if (this.observed.hasListener(w._other)) {
|
||||||
this.observed.removeListener(w._other);
|
this.observed.removeListener(w);
|
||||||
if (this.last === w) return this.defaultResult;
|
if (this.last !== w) return this.defaultResult;
|
||||||
} else if (this.installed) {
|
} else if (this.installed) {
|
||||||
this.observed.addListener(w._other, ...this.extras);
|
this.observed.addListener(w._other, ...this.extras);
|
||||||
this.last = w._other;
|
this.last = w._other;
|
||||||
}
|
}
|
||||||
|
debug("Running listener", w === ww[0] ? 0 : 1, ...args);
|
||||||
return this.installed ? this.listener(...args)
|
return this.installed ? this.listener(...args)
|
||||||
: this.defaultResult;
|
: this.defaultResult;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue