[TabGuard] Better request lifecycle management.
This commit is contained in:
parent
4f9c27a39e
commit
46dc62866d
|
@ -655,6 +655,7 @@ var RequestGuard = (() => {
|
||||||
let {requestId, url, tabId, frameId, type} = request;
|
let {requestId, url, tabId, frameId, type} = request;
|
||||||
if (type === "main_frame") {
|
if (type === "main_frame") {
|
||||||
TabStatus.initTab(tabId);
|
TabStatus.initTab(tabId);
|
||||||
|
TabGuard.postCheck(request);
|
||||||
}
|
}
|
||||||
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")
|
||||||
|
@ -687,9 +688,11 @@ var RequestGuard = (() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TabGuard.postCheck(request);
|
||||||
},
|
},
|
||||||
onErrorOccurred(request) {
|
onErrorOccurred(request) {
|
||||||
pendingRequests.delete(request.requestId);
|
pendingRequests.delete(request.requestId);
|
||||||
|
TabGuard.postCheck(request);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function fakeRequestFromCSP(report, request) {
|
function fakeRequestFromCSP(report, request) {
|
||||||
|
|
|
@ -44,6 +44,8 @@ var TabGuard = (() => {
|
||||||
return flat;
|
return flat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let cutRequestIds = new Set();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
forget,
|
forget,
|
||||||
check(request) {
|
check(request) {
|
||||||
|
@ -62,9 +64,12 @@ var TabGuard = (() => {
|
||||||
if (mainFrame) {
|
if (mainFrame) {
|
||||||
let headers = flattenHeaders(requestHeaders);
|
let headers = flattenHeaders(requestHeaders);
|
||||||
if (headers["sec-fetch-user"] === "?1" && /^(?:same-(?:site|origin)|none)$/i.test(headers["sec-fetch-site"])) {
|
if (headers["sec-fetch-user"] === "?1" && /^(?:same-(?:site|origin)|none)$/i.test(headers["sec-fetch-site"])) {
|
||||||
debug("[TabGuard] User-typed, bookmark, reload or user-activated same-site navigation: cutting tab ties.", request);
|
debug("[TabGuard] User-typed, bookmark, reload or user-activated same-site navigation: scheduling tab ties cut.", tabId, request);
|
||||||
TabTies.cut(tabId);
|
cutRequestIds.add(tabId);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
debug("[TabGuard] Automatic or cross-site navigation, keeping tab ties.", tabId, request);
|
||||||
|
cutRequestIds.delete(tabId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +127,13 @@ var TabGuard = (() => {
|
||||||
}
|
}
|
||||||
let mustFilter = mainFrame || quietDomains && [...otherDomains].some(d => quietDomains.has(d))
|
let mustFilter = mainFrame || quietDomains && [...otherDomains].some(d => quietDomains.has(d))
|
||||||
return mustFilter ? filterAuth() : null;
|
return mustFilter ? filterAuth() : null;
|
||||||
|
},
|
||||||
|
postCheck(request) {
|
||||||
|
let {requestId, tabId} = request;
|
||||||
|
if (cutRequestIds.has(requestId)) {
|
||||||
|
cutRequestIds.remove(requestId);
|
||||||
|
TabTies.cut(tabId);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in New Issue