mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01:00
Better report secondary requests with quick redirections
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1241 uBO will not discard secondary requests fired before a root frame is committed, by ensuring that if newly uncommitted root frames are of the same origin as previous one(s), the uncommited journal slot pointer is not updated.
This commit is contained in:
parent
4f53e08741
commit
70cabc1cc6
@ -226,9 +226,9 @@ const PageStore = class {
|
|||||||
constructor(tabId, context) {
|
constructor(tabId, context) {
|
||||||
this.extraData = new Map();
|
this.extraData = new Map();
|
||||||
this.journal = [];
|
this.journal = [];
|
||||||
this.journalTimer = null;
|
this.journalTimer = undefined;
|
||||||
this.journalLastCommitted = this.journalLastUncommitted = undefined;
|
this.journalLastCommitted = this.journalLastUncommitted = -1;
|
||||||
this.journalLastUncommittedURL = undefined;
|
this.journalLastUncommittedOrigin = undefined;
|
||||||
this.netFilteringCache = NetFilteringResultCache.factory();
|
this.netFilteringCache = NetFilteringResultCache.factory();
|
||||||
this.init(tabId, context);
|
this.init(tabId, context);
|
||||||
}
|
}
|
||||||
@ -351,12 +351,12 @@ const PageStore = class {
|
|||||||
this.largeMediaTimer = null;
|
this.largeMediaTimer = null;
|
||||||
}
|
}
|
||||||
this.disposeFrameStores();
|
this.disposeFrameStores();
|
||||||
if ( this.journalTimer !== null ) {
|
if ( this.journalTimer !== undefined ) {
|
||||||
clearTimeout(this.journalTimer);
|
clearTimeout(this.journalTimer);
|
||||||
this.journalTimer = null;
|
this.journalTimer = undefined;
|
||||||
}
|
}
|
||||||
this.journal = [];
|
this.journal = [];
|
||||||
this.journalLastUncommittedURL = undefined;
|
this.journalLastUncommittedOrigin = undefined;
|
||||||
if ( pageStoreJunkyard.length < pageStoreJunkyardMax ) {
|
if ( pageStoreJunkyard.length < pageStoreJunkyardMax ) {
|
||||||
pageStoreJunkyard.push(this);
|
pageStoreJunkyard.push(this);
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ const PageStore = class {
|
|||||||
hostname,
|
hostname,
|
||||||
result === 1 ? 0x00000001 : 0x00010000
|
result === 1 ? 0x00000001 : 0x00010000
|
||||||
);
|
);
|
||||||
if ( this.journalTimer === null ) {
|
if ( this.journalTimer === undefined ) {
|
||||||
this.journalTimer = vAPI.setTimeout(
|
this.journalTimer = vAPI.setTimeout(
|
||||||
( ) => { this.journalProcess(true); },
|
( ) => { this.journalProcess(true); },
|
||||||
µb.hiddenSettings.requestJournalProcessPeriod
|
µb.hiddenSettings.requestJournalProcessPeriod
|
||||||
@ -475,18 +475,23 @@ const PageStore = class {
|
|||||||
if ( type === 'committed' ) {
|
if ( type === 'committed' ) {
|
||||||
this.journalLastCommitted = this.journal.length;
|
this.journalLastCommitted = this.journal.length;
|
||||||
if (
|
if (
|
||||||
this.journalLastUncommitted !== undefined &&
|
this.journalLastUncommitted !== -1 &&
|
||||||
this.journalLastUncommitted < this.journalLastCommitted &&
|
this.journalLastUncommitted < this.journalLastCommitted &&
|
||||||
this.journalLastUncommittedURL === url
|
this.journalLastUncommittedOrigin === vAPI.hostnameFromURI(url)
|
||||||
) {
|
) {
|
||||||
this.journalLastCommitted = this.journalLastUncommitted;
|
this.journalLastCommitted = this.journalLastUncommitted;
|
||||||
this.journalLastUncommitted = undefined;
|
|
||||||
}
|
}
|
||||||
} else if ( type === 'uncommitted' ) {
|
} else if ( type === 'uncommitted' ) {
|
||||||
|
const newOrigin = vAPI.hostnameFromURI(url);
|
||||||
|
if (
|
||||||
|
this.journalLastUncommitted === -1 ||
|
||||||
|
this.journalLastUncommittedOrigin !== newOrigin
|
||||||
|
) {
|
||||||
this.journalLastUncommitted = this.journal.length;
|
this.journalLastUncommitted = this.journal.length;
|
||||||
this.journalLastUncommittedURL = url;
|
this.journalLastUncommittedOrigin = newOrigin;
|
||||||
}
|
}
|
||||||
if ( this.journalTimer !== null ) {
|
}
|
||||||
|
if ( this.journalTimer !== undefined ) {
|
||||||
clearTimeout(this.journalTimer);
|
clearTimeout(this.journalTimer);
|
||||||
}
|
}
|
||||||
this.journalTimer = vAPI.setTimeout(
|
this.journalTimer = vAPI.setTimeout(
|
||||||
@ -495,16 +500,14 @@ const PageStore = class {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
journalProcess(fromTimer) {
|
journalProcess(fromTimer = false) {
|
||||||
if ( !fromTimer ) {
|
if ( fromTimer === false ) { clearTimeout(this.journalTimer); }
|
||||||
clearTimeout(this.journalTimer);
|
this.journalTimer = undefined;
|
||||||
}
|
|
||||||
this.journalTimer = null;
|
|
||||||
|
|
||||||
const journal = this.journal;
|
const journal = this.journal;
|
||||||
|
const pivot = this.journalLastCommitted || 0;
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
let aggregateCounts = 0;
|
let aggregateCounts = 0;
|
||||||
let pivot = this.journalLastCommitted || 0;
|
|
||||||
|
|
||||||
// Everything after pivot originates from current page.
|
// Everything after pivot originates from current page.
|
||||||
for ( let i = pivot; i < journal.length; i += 2 ) {
|
for ( let i = pivot; i < journal.length; i += 2 ) {
|
||||||
@ -520,7 +523,7 @@ const PageStore = class {
|
|||||||
}
|
}
|
||||||
this.perLoadBlockedRequestCount += aggregateCounts & 0xFFFF;
|
this.perLoadBlockedRequestCount += aggregateCounts & 0xFFFF;
|
||||||
this.perLoadAllowedRequestCount += aggregateCounts >>> 16 & 0xFFFF;
|
this.perLoadAllowedRequestCount += aggregateCounts >>> 16 & 0xFFFF;
|
||||||
this.journalLastCommitted = undefined;
|
this.journalLastUncommitted = this.journalLastCommitted = -1;
|
||||||
|
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/905#issuecomment-76543649
|
// https://github.com/chrisaljoudi/uBlock/issues/905#issuecomment-76543649
|
||||||
// No point updating the badge if it's not being displayed.
|
// No point updating the badge if it's not being displayed.
|
||||||
|
Loading…
Reference in New Issue
Block a user