Skip to content

Commit

Permalink
Use effective frame URL for about:blank frames
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Dec 6, 2021
1 parent 3004c88 commit 55fc4ba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/js/pagestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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; }
Expand All @@ -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();
}
Expand Down

0 comments on commit 55fc4ba

Please sign in to comment.