Partially bring suspendTabsUntilReady out of experimental status

This commit will force-reload active tabs at launch for
environments not supporting suspend network request listeners,
or configured to not suspend network request listeners.
This commit is contained in:
Raymond Hill 2021-12-18 11:26:50 -05:00
parent edab87b4bc
commit a0a9497b4a
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 17 additions and 3 deletions

View File

@ -304,7 +304,7 @@ const onHiddenSettingsReady = async function() {
});
}
// Matbe override default cache storage
// Maybe override default cache storage
const cacheBackend = await cacheStorage.select(
µb.hiddenSettings.cacheStorageAPI
);

View File

@ -1138,7 +1138,7 @@ const webRequest = {
vAPI.net = new vAPI.Net();
vAPI.net.suspend();
return ( ) => {
return async ( ) => {
vAPI.net.setSuspendableListener(onBeforeRequest);
vAPI.net.addListener(
'onHeadersReceived',
@ -1146,7 +1146,21 @@ const webRequest = {
{ urls: [ 'http://*/*', 'https://*/*' ] },
[ 'blocking', 'responseHeaders' ]
);
vAPI.net.unsuspend(true);
vAPI.net.unsuspend({ force: true });
// Mitigation: force-reload active tabs for environments not
// supporting suspended network request listeners.
if (
vAPI.net.canSuspend() !== true ||
µb.hiddenSettings.suspendTabsUntilReady === 'no'
) {
const tabs = await vAPI.tabs.query({
active: true,
windowType: 'normal',
});
for ( const tab of tabs ) {
vAPI.tabs.reload(tab.id);
}
}
};
})(),