1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

Use effective frame URL for about:blank frames

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1858
This commit is contained in:
Raymond Hill 2021-12-06 11:59:48 -05:00
parent 3004c8832a
commit 55fc4ba5e5
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -219,6 +219,14 @@ const FrameStore = class {
return null; return null;
} }
updateURL(url) {
if ( typeof url !== 'string' ) { return; }
this.rawURL = url;
this.hostname = hostnameFromURI(url);
this.domain = domainFromHostname(this.hostname) || this.hostname;
this._cosmeticFilteringBits = undefined;
}
getCosmeticFilteringBits(tabId) { getCosmeticFilteringBits(tabId) {
if ( this._cosmeticFilteringBits !== undefined ) { if ( this._cosmeticFilteringBits !== undefined ) {
return this._cosmeticFilteringBits; return this._cosmeticFilteringBits;
@ -488,6 +496,8 @@ const PageStore = class {
return this.frames.get(frameId) || null; return this.frames.get(frameId) || null;
} }
// https://github.com/uBlockOrigin/uBlock-issues/issues/1858
// Mind that setFrameURL() can be called from navigation event handlers.
setFrameURL(details) { setFrameURL(details) {
let { frameId, url, parentFrameId } = details; let { frameId, url, parentFrameId } = details;
if ( frameId === undefined ) { frameId = 0; } if ( frameId === undefined ) { frameId = 0; }
@ -504,6 +514,9 @@ const PageStore = class {
frameStore = FrameStore.factory(url, parentFrameId); frameStore = FrameStore.factory(url, parentFrameId);
this.frames.set(frameId, frameStore); this.frames.set(frameId, frameStore);
this.frameAddCount += 1; this.frameAddCount += 1;
if ( url.startsWith('about:') ) {
frameStore.updateURL(this.getEffectiveFrameURL({ frameId }));
}
if ( (this.frameAddCount & 0b111111) === 0 ) { if ( (this.frameAddCount & 0b111111) === 0 ) {
this.pruneFrames(); this.pruneFrames();
} }