Cancel requests with the same requestId
Prevents potential redirects from opening two tabs Closes #1114
This commit is contained in:
parent
22ec01d565
commit
7dceaf6679
1 changed files with 16 additions and 0 deletions
|
@ -144,6 +144,21 @@ const assignManager = {
|
|||
return {};
|
||||
}
|
||||
|
||||
// we decided to cancel the request at this point, register it as canceled request as early as possible
|
||||
if (!this.canceledRequests[options.requestId]) {
|
||||
this.canceledRequests[options.requestId] = true;
|
||||
// register a cleanup for handled requestIds
|
||||
// all relevant requests that come in that timeframe with the same requestId will be canceled
|
||||
setTimeout(() => {
|
||||
delete this.canceledRequests[options.requestId];
|
||||
}, 2000);
|
||||
} else {
|
||||
// if we see a request for the same requestId at this point then this is a redirect that we have to cancel to prevent opening two tabs
|
||||
return {
|
||||
cancel: true
|
||||
};
|
||||
}
|
||||
|
||||
this.reloadPageInContainer(options.url, userContextId, siteSettings.userContextId, tab.index + 1, tab.active, siteSettings.neverAsk);
|
||||
this.calculateContextMenu(tab);
|
||||
|
||||
|
@ -174,6 +189,7 @@ const assignManager = {
|
|||
});
|
||||
|
||||
// Before a request is handled by the browser we decide if we should route through a different container
|
||||
this.canceledRequests = {};
|
||||
browser.webRequest.onBeforeRequest.addListener((options) => {
|
||||
return this.onBeforeRequest(options);
|
||||
},{urls: ["<all_urls>"], types: ["main_frame"]}, ["blocking"]);
|
||||
|
|
Loading…
Add table
Reference in a new issue