From f39d87f6e049319addb45923bb73a4bba0548363 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 27 Jan 2016 11:02:08 -0500 Subject: [PATCH] this fixes #1305 --- platform/firefox/frameModule.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 104caddc9..ddaae97bd 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -154,7 +154,7 @@ var contentObserver = { .outerWindowID; }, - handlePopup: function(location, context) { + handlePopup: function(location, origin, context) { let openeeContext = context.contentWindow || context; if ( typeof openeeContext.opener !== 'object' || @@ -168,10 +168,19 @@ var contentObserver = { // Use location of top window, not that of a frame, as this // would cause tab id lookup (necessary for popup blocking) to // always fail. - let openerURL = openeeContext.opener.top && - openeeContext.opener.top.location.href; + // Opener could be a dead object, using it would cause a throw. + // Repro case: + // - Open http://delishows.to/show/chicago-med/season/1/episode/6 + // - Click anywhere in the background + let openerURL = null; + try { + let opener = openeeContext.opener.top || openeeContext.opener; + openerURL = opener.location && opener.location.href; + } catch(ex) { + } + // If no valid opener URL found, use the origin URL. if ( openerURL === null ) { - return; + openerURL = origin.asciiSpec; } let messageManager = getMessageManager(openeeContext); if ( messageManager === null ) { @@ -204,7 +213,7 @@ var contentObserver = { } if ( type === this.MAIN_FRAME ) { - this.handlePopup(location, context); + this.handlePopup(location, origin, context); } if ( !location.schemeIs('http') && !location.schemeIs('https') ) {