@@ -884,7 +884,7 @@ vAPI.Tabs = class extends vAPI.Tabs {
884
884
const { frameId, tabId, url } = details ;
885
885
if ( frameId === 0 ) {
886
886
µb . tabContextManager . commit ( tabId , url ) ;
887
- const pageStore = µb . bindTabToPageStore ( tabId , 'tabCommitted' ) ;
887
+ const pageStore = µb . bindTabToPageStore ( tabId , 'tabCommitted' , details ) ;
888
888
if ( pageStore !== null ) {
889
889
pageStore . journalAddRootFrame ( 'committed' , url ) ;
890
890
}
@@ -910,7 +910,7 @@ vAPI.Tabs = class extends vAPI.Tabs {
910
910
if ( ! tab . url || tab . url === '' ) { return ; }
911
911
if ( ! changeInfo . url ) { return ; }
912
912
µBlock . tabContextManager . commit ( tabId , changeInfo . url ) ;
913
- µBlock . bindTabToPageStore ( tabId , 'tabUpdated' ) ;
913
+ µBlock . bindTabToPageStore ( tabId , 'tabUpdated' , tab ) ;
914
914
}
915
915
} ;
916
916
@@ -921,7 +921,7 @@ vAPI.tabs = new vAPI.Tabs();
921
921
922
922
// Create an entry for the tab if it doesn't exist.
923
923
924
- µBlock . bindTabToPageStore = function ( tabId , context ) {
924
+ µBlock . bindTabToPageStore = function ( tabId , context , details = undefined ) {
925
925
this . updateToolbarIcon ( tabId , 0b111 ) ;
926
926
927
927
// Do not create a page store for URLs which are of no interests
@@ -935,8 +935,7 @@ vAPI.tabs = new vAPI.Tabs();
935
935
936
936
// Tab is not bound
937
937
if ( pageStore === undefined ) {
938
- this . updateTitle ( tabId ) ;
939
- pageStore = this . PageStore . factory ( tabId , context ) ;
938
+ pageStore = this . PageStore . factory ( tabId , details ) ;
940
939
this . pageStores . set ( tabId , pageStore ) ;
941
940
this . pageStoresToken = Date . now ( ) ;
942
941
return pageStore ;
@@ -958,9 +957,8 @@ vAPI.tabs = new vAPI.Tabs();
958
957
// Rebind according to context. We rebind even if the URL did not change,
959
958
// as maybe the tab was force-reloaded, in which case the page stats must
960
959
// be all reset.
961
- pageStore . reuse ( context ) ;
960
+ pageStore . reuse ( context , details ) ;
962
961
963
- this . updateTitle ( tabId ) ;
964
962
this . pageStoresToken = Date . now ( ) ;
965
963
966
964
return pageStore ;
@@ -1094,58 +1092,6 @@ vAPI.tabs = new vAPI.Tabs();
1094
1092
1095
1093
/******************************************************************************/
1096
1094
1097
- µBlock . updateTitle = ( ( ) => {
1098
- const tabIdToCount = new Map ( ) ;
1099
- const delay = 499 ;
1100
-
1101
- const updateTitle = async function ( tabId ) {
1102
- let count = tabIdToCount . get ( tabId ) ;
1103
- if ( count === undefined ) { return ; }
1104
- tabIdToCount . delete ( tabId ) ;
1105
- const tab = await vAPI . tabs . get ( tabId ) ;
1106
- if ( tab instanceof Object === false || tab . discarded === true ) {
1107
- return ;
1108
- }
1109
- const µb = µBlock ;
1110
- const pageStore = µb . pageStoreFromTabId ( tabId ) ;
1111
- if ( pageStore === null ) { return ; }
1112
- // Firefox needs this: if you detach a tab, the new tab won't have
1113
- // its rawURL set. Concretely, this causes the logger to report an
1114
- // entry to itself in the logger's tab selector.
1115
- // TODO: Investigate for a fix vAPI-side.
1116
- pageStore . rawURL = tab . url ;
1117
- µb . pageStoresToken = Date . now ( ) ;
1118
- // https://github.com/gorhill/uMatrix/issues/225
1119
- // Sometimes title changes while page is loading.
1120
- const settled =
1121
- typeof tab . title === 'string' &&
1122
- tab . title !== '' &&
1123
- tab . title === pageStore . title ;
1124
- pageStore . title = tab . title || tab . url || '' ;
1125
- if ( settled ) { return ; }
1126
- if ( tabIdToCount . has ( tabId ) ) { return ; }
1127
- count -= 1 ;
1128
- if ( count === 0 ) { return ; }
1129
- tabIdToCount . set ( tabId , count ) ;
1130
- updateTitleAsync ( tabId ) ;
1131
- } ;
1132
-
1133
- const updateTitleAsync = function ( tabId ) {
1134
- vAPI . setTimeout ( ( ) => { updateTitle ( tabId ) ; } , delay ) ;
1135
- } ;
1136
-
1137
- return function ( tabId ) {
1138
- if ( vAPI . isBehindTheSceneTabId ( tabId ) ) { return ; }
1139
- const count = tabIdToCount . get ( tabId ) ;
1140
- tabIdToCount . set ( tabId , 5 ) ;
1141
- if ( count === undefined ) {
1142
- updateTitleAsync ( tabId ) ;
1143
- }
1144
- } ;
1145
- } ) ( ) ;
1146
-
1147
- /******************************************************************************/
1148
-
1149
1095
// https://github.com/chrisaljoudi/uBlock/issues/455
1150
1096
// Stale page store entries janitor
1151
1097
0 commit comments