This commit is contained in:
gorhill 2016-01-27 11:02:08 -05:00
parent 5a9f3fa6fe
commit f39d87f6e0
1 changed files with 14 additions and 5 deletions

View File

@ -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') ) {