[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;
|
||||
if (type === "main_frame") {
|
||||
TabStatus.initTab(tabId);
|
||||
TabGuard.postCheck(request);
|
||||
}
|
||||
let scriptBlocked = request.responseHeaders.some(
|
||||
h => csp.isMine(h) && csp.blocks(h.value, "script")
|
||||
|
@ -687,9 +688,11 @@ var RequestGuard = (() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
TabGuard.postCheck(request);
|
||||
},
|
||||
onErrorOccurred(request) {
|
||||
pendingRequests.delete(request.requestId);
|
||||
TabGuard.postCheck(request);
|
||||
}
|
||||
};
|
||||
function fakeRequestFromCSP(report, request) {
|
||||
|
|
|
@ -44,6 +44,8 @@ var TabGuard = (() => {
|
|||
return flat;
|
||||
}
|
||||
|
||||
let cutRequestIds = new Set();
|
||||
|
||||
return {
|
||||
forget,
|
||||
check(request) {
|
||||
|
@ -62,9 +64,12 @@ var TabGuard = (() => {
|
|||
if (mainFrame) {
|
||||
let headers = flattenHeaders(requestHeaders);
|
||||
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);
|
||||
TabTies.cut(tabId);
|
||||
debug("[TabGuard] User-typed, bookmark, reload or user-activated same-site navigation: scheduling tab ties cut.", tabId, request);
|
||||
cutRequestIds.add(tabId);
|
||||
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))
|
||||
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