Clear unprocessed requests status on webNavigation reload event

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/discussions/2564
This commit is contained in:
Raymond Hill 2023-03-30 17:12:45 -04:00
parent a6071565a5
commit 0b09155268
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 14 additions and 4 deletions

View File

@ -211,6 +211,12 @@ vAPI.Tabs = class {
this.onCreatedNavigationTargetHandler(details);
});
browser.webNavigation.onCommitted.addListener(details => {
const { frameId, tabId } = details;
if ( frameId === 0 && tabId > 0 && details.transitionType === 'reload' ) {
if ( vAPI.net && vAPI.net.hasUnprocessedRequest(tabId) ) {
vAPI.net.removeUnprocessedRequest(tabId);
}
}
this.onCommittedHandler(details);
});
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
@ -1268,10 +1274,7 @@ vAPI.Net = class {
listener = details => {
const { tabId, type } = details;
if ( type === 'main_frame' && this.unprocessedTabs.has(tabId) ) {
this.unprocessedTabs.delete(tabId);
if ( this.unprocessedTabs.size === 0 ) {
this.suspendableListener = this.deferredSuspendableListener;
this.deferredSuspendableListener = undefined;
if ( this.removeUnprocessedRequest(tabId) ) {
return this.suspendableListener(details);
}
}
@ -1311,6 +1314,13 @@ vAPI.Net = class {
return this.unprocessedTabs.size !== 0 &&
this.unprocessedTabs.has(tabId);
}
removeUnprocessedRequest(tabId) {
this.unprocessedTabs.delete(tabId);
if ( this.unprocessedTabs.size !== 0 ) { return false; }
this.suspendableListener = this.deferredSuspendableListener;
this.deferredSuspendableListener = undefined;
return true;
}
suspendOneRequest() {
}
unsuspendAllRequests() {