diff --git a/mozilla/suite/common/nsContextMenu.js b/mozilla/suite/common/nsContextMenu.js index f5c57ff8aad..dbef92e28e8 100644 --- a/mozilla/suite/common/nsContextMenu.js +++ b/mozilla/suite/common/nsContextMenu.js @@ -622,7 +622,7 @@ nsContextMenu.prototype = { }, // Open clicked-in frame in the same window showOnlyThisFrame : function () { - window.loadURI(this.target.ownerDocument.location.href); + openTopWin( this.target.ownerDocument.location.href, this.target.ownerDocument.defaultView ); }, // View Partial Source viewPartialSource : function ( context ) { @@ -671,12 +671,12 @@ nsContextMenu.prototype = { // Change current window to the URL of the image. viewImage : function () { urlSecurityCheck( this.imageURL, document ); - openTopWin( this.imageURL ); + openTopWin( this.imageURL, this.target.ownerDocument.defaultView ); }, // Change current window to the URL of the background image. viewBGImage : function () { urlSecurityCheck( this.bgImageURL, document ); - openTopWin( this.bgImageURL ); + openTopWin( this.bgImageURL, this.target.ownerDocument.defaultView ); }, setWallpaper: function() { // Confirm since it's annoying if you hit this accidentally. diff --git a/mozilla/suite/common/utilityOverlay.js b/mozilla/suite/common/utilityOverlay.js index 3ccf2c8b807..a0cb8774977 100644 --- a/mozilla/suite/common/utilityOverlay.js +++ b/mozilla/suite/common/utilityOverlay.js @@ -329,7 +329,20 @@ function getTopWin() return null; } -function openTopWin( url ) +function isRestricted( url ) +{ + try { + const nsIURIFixup = Components.interfaces.nsIURIFixup; + var uriFixup = Components.classes["@mozilla.org/docshell/urifixup;1"] + .getService(nsIURIFixup); + var url = uriFixup.createFixupURI(url, nsIURIFixup.FIXUP_FLAG_NONE); + return url.schemeIs("javascript") || url.schemeIs("data"); + } catch (e) { + return false; + } +} + +function openTopWin( url, opener ) { /* note that this chrome url should probably change to not have all of the navigator controls, but if we do this we need to have @@ -347,8 +360,15 @@ function openTopWin( url ) var topWindowOfType = getTopWin(); if ( topWindowOfType ) { - topWindowOfType.focus(); - topWindowOfType.loadURI(url); + if (opener && topWindowOfType.content == opener.top) + opener.open(url, "_top"); + else if (opener && isRestricted(url)) + topWindowOfType.getBrowser().loadURIWithFlags(url, + Components.interfaces.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL); + else + topWindowOfType.loadURI(url); + + topWindowOfType.content.focus(); return topWindowOfType; } return window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );