From 55fc4ba5e5727a93b22a52abc441030ad467d9f0 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 6 Dec 2021 11:59:48 -0500 Subject: [PATCH] Use effective frame URL for `about:blank` frames Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1858 --- src/js/pagestore.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/js/pagestore.js b/src/js/pagestore.js index d9987012d..1c2ab32e6 100644 --- a/src/js/pagestore.js +++ b/src/js/pagestore.js @@ -219,6 +219,14 @@ const FrameStore = class { 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) { if ( this._cosmeticFilteringBits !== undefined ) { return this._cosmeticFilteringBits; @@ -488,6 +496,8 @@ const PageStore = class { 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) { let { frameId, url, parentFrameId } = details; if ( frameId === undefined ) { frameId = 0; } @@ -504,6 +514,9 @@ const PageStore = class { frameStore = FrameStore.factory(url, parentFrameId); this.frames.set(frameId, frameStore); this.frameAddCount += 1; + if ( url.startsWith('about:') ) { + frameStore.updateURL(this.getEffectiveFrameURL({ frameId })); + } if ( (this.frameAddCount & 0b111111) === 0 ) { this.pruneFrames(); }