Skip to content

Commit

Permalink
Context of about:blank is that of parent frame (popup option)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 10, 2023
1 parent 3c4c376 commit 574f30e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/js/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,24 @@ const onPopupUpdated = (( ) => {
if ( tabContext === null ) { return; }
const rootOpenerURL = tabContext.rawURL;
if ( rootOpenerURL === '' ) { return; }
const localOpenerURL = openerDetails.frameId !== 0
const pageStore = µb.pageStoreFromTabId(openerTabId);

// https://github.com/uBlockOrigin/uBlock-issues/discussions/2534#discussioncomment-5264792
// An `about:blank` frame's context is that of the parent context
let localOpenerURL = openerDetails.frameId !== 0
? openerDetails.frameURL
: undefined;
if ( localOpenerURL === 'about:blank' && pageStore !== null ) {
let openerFrameId = openerDetails.frameId;
do {
const frame = pageStore.getFrameStore(openerFrameId);
if ( frame === null ) { break; }
openerFrameId = frame.parentId;
const parentFrame = pageStore.getFrameStore(openerFrameId);
if ( parentFrame === null ) { break; }
localOpenerURL = parentFrame.frameURL;
} while ( localOpenerURL === 'about:blank' && openerFrameId !== 0 );
}

// Popup details.
tabContext = µb.tabContextManager.lookup(targetTabId);
Expand Down Expand Up @@ -392,7 +407,6 @@ const onPopupUpdated = (( ) => {

// Only if a popup was blocked do we report it in the dynamic
// filtering pane.
const pageStore = µb.pageStoreFromTabId(openerTabId);
if ( pageStore ) {
pageStore.journalAddRequest(fctxt, result);
pageStore.popupBlockedCount += 1;
Expand Down

0 comments on commit 574f30e

Please sign in to comment.