diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 87528878413..268bde89812 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -31,6 +31,7 @@ # Joe Hewitt # Alec Flett # Asaf Romano +# Jason Barnabe # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -1892,10 +1893,11 @@ function BrowserViewSourceOfURL(url, charset, pageCookie) // doc=null for regular page info, doc=owner document for frame info. function BrowserPageInfo(doc) { - window.openDialog("chrome://browser/content/pageInfo.xul", - "_blank", - "chrome,dialog=no", - doc); + toOpenDialogByTypeAndUrl("Browser:page-info", + doc ? doc.location : window.content.document.location, + "chrome://browser/content/pageInfo.xul", + "chrome,dialog=no", + doc); } #ifdef DEBUG @@ -2763,6 +2765,27 @@ function toOpenWindowByType(inType, uri, features) window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar"); } +function toOpenDialogByTypeAndUrl(inType, relatedUrl, windowUri, features, extraArgument) +{ + var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(); + var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); + var windows = windowManagerInterface.getEnumerator(inType); + + // Check for windows matching the url + while (windows.hasMoreElements()) { + var currentWindow = windows.getNext(); + if (currentWindow.document.firstChild.getAttribute("relatedUrl") == relatedUrl) { + currentWindow.focus(); + return; + } + } + + // We didn't find a matching window, so open a new one. + if (features) + window.openDialog(windowUri, "_blank", features, extraArgument); + else + window.openDialog(windowUri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", extraArgument); +} function OpenBrowserWindow() { diff --git a/browser/base/content/pageInfo.js b/browser/base/content/pageInfo.js index 0b7776792a5..cba58f32651 100644 --- a/browser/base/content/pageInfo.js +++ b/browser/base/content/pageInfo.js @@ -290,6 +290,8 @@ function onLoadPageInfo() } document.title = docTitle; + + document.getElementById("main-window").setAttribute("relatedUrl", theDocument.location.toString()); // do the easy stuff first makeGeneralTab();