Skip to content

Commit

Permalink
Detect search result tabs opened from about:addons #2397
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Oct 28, 2019
1 parent dc532d7 commit 86297bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions webextensions/background/handle-new-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,20 @@ Tab.onUpdated.addListener((tab, changeInfo) => {
});
return;
}

log('checking special openers (delayed)', { opener: possibleOpenerTab.url, child: tab.url });
for (const rule of Constants.kAGGRESSIVE_OPENER_TAB_DETECTION_RULES_WITH_URL) {
if (rule.opener.test(possibleOpenerTab.url) &&
rule.child.test(tab.url)) {
log('behave as a tab opened from special opener (delayed)', { rule });
handleNewTabFromActiveTab(tab, {
url: tab.url,
activeTab: possibleOpenerTab,
autoAttachBehavior: Constants.kNEWTAB_OPEN_AS_CHILD
});
return;
}
}
}
});

Expand Down
5 changes: 5 additions & 0 deletions webextensions/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,9 @@ export const kSHORTHAND_URIS = {
'test-runner': browser.extension.getURL('tests/runner.html')
};

export const kAGGRESSIVE_OPENER_TAB_DETECTION_RULES_WITH_URL = [
{ opener: /^about:addons/,
child: /^https:\/\/addons.mozilla.org\/([^\/]+\/)?[^\/]+\/search\// }
];

export const kNOTIFICATION_DEFAULT_ICON = '/resources/icon64.png';

0 comments on commit 86297bb

Please sign in to comment.