From 32c7bf854bef2ae4669aa6371f80bbece651e020 Mon Sep 17 00:00:00 2001 From: Deathamns Date: Thu, 15 Jan 2015 15:58:14 +0100 Subject: [PATCH] Firefox: fix tab closing issue (pop-up blocking) --- platform/firefox/frameModule.js | 8 ++++++-- platform/firefox/vapi-background.js | 11 +++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 8fa551980..ad24e495f 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -127,7 +127,9 @@ const contentObserver = { context = context.contentWindow || context; try { - openerURL = context.opener.location.href; + if ( context !== context.opener ) { + openerURL = context.opener.location.href; + } } catch (ex) {} let isPopup = location.spec === 'about:blank' && openerURL; @@ -139,7 +141,9 @@ const contentObserver = { context = context.contentWindow || context; try { - openerURL = context.opener.location.href; + if ( context !== context.opener ) { + openerURL = context.opener.location.href; + } } catch (ex) {} } else { context = (context.ownerDocument || context).defaultView; diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 2d608307e..b37fd1b3d 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -980,10 +980,17 @@ var httpObserver = { var tabURI = tab.linkedBrowser.currentURI; // Probably isn't the best method to identify the source tab - if ( tabURI.spec === this.lastRequest.openerURL ) { - sourceTabId = vAPI.tabs.getTabId(tab); + if ( tabURI.spec !== lastRequest.openerURL ) { + continue + } + + sourceTabId = vAPI.tabs.getTabId(tab); + + if ( sourceTabId !== lastRequest.tabId ) { break; } + + sourceTabId = null; } if ( this.handlePopup(channel.URI, lastRequest.tabId, sourceTabId) ) {