From 1a42894f3ee1f4b8e022dcd943d05314e32cc99e Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Thu, 18 Aug 2016 22:53:23 +0900 Subject: [PATCH] Detect opener tab more correctly even if a new tab is requested from a subframe contents --- modules/window.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/window.js b/modules/window.js index 2f92076d..562778bb 100644 --- a/modules/window.js +++ b/modules/window.js @@ -1413,7 +1413,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, { } }, - onBeforeBrowserAccessOpenURI : function TSTWindow_onBeforeBrowserAccessOpenURI(aParamsOrOpener, aWhere) + onBeforeBrowserAccessOpenURI : function TSTWindow_onBeforeBrowserAccessOpenURI(aParamsOrOpener, aWhere, aContext) { var hasOwnerTab = false; var opener = null; @@ -1431,11 +1431,14 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, { // from remote contents, we have to detect its opener from the URI. let referrer = aParamsOrOpener.referrer; if (referrer) { + let referrerHash = utils.getHashString(referrer); let activeTab = this.browser.selectedTab; let possibleOwners = [activeTab].concat(this.getAncestorTabs(activeTab)); for (let i = 0, maxi = possibleOwners.length; i < maxi; i++) { let possibleOwner = possibleOwners[i]; - if (possibleOwner.linkedBrowser.currentURI.spec != referrer) + let contentLocations = possibleOwner.__treestyletab__contentLocations || + [utils.getHashString(possibleOwner.linkedBrowser.currentURI.spec)]; + if (contentLocations.indexOf(referrerHash) < 0) continue; hasOwnerTab = true; opener = possibleOwner.linkedBrowser;