Fix bug 342504. r=gavin/neil, sr=bsmedberg

This commit is contained in:
bzbarsky@mit.edu 2007-12-14 09:27:31 -08:00
parent fa126fa8b6
commit 64ef6913a8
3 changed files with 36 additions and 25 deletions

View File

@ -3816,9 +3816,11 @@ nsBrowserAccess.prototype =
aWhere = gPrefService.getIntPref("browser.link.open_newwindow");
}
}
var url = aURI ? aURI.spec : "about:blank";
switch(aWhere) {
case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW :
// FIXME: Bug 408379. So how come this doesn't send the
// referrer like the other loads do?
var url = aURI ? aURI.spec : "about:blank";
newWindow = openDialog(getBrowserURL(), "_blank", "all,dialog=no", url);
break;
case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
@ -3828,16 +3830,18 @@ nsBrowserAccess.prototype =
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
try {
if (aOpener) {
location = aOpener.location;
referrer =
Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(location, null, null);
if (aURI) {
if (aOpener) {
location = aOpener.location;
referrer =
Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(location, null, null);
}
newWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.loadURI(aURI.spec, loadflags, referrer, null, null);
}
newWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.loadURI(url, loadflags, referrer, null, null);
if (!loadInBackground && isExternal)
newWindow.focus();
} catch(e) {
@ -3847,20 +3851,25 @@ nsBrowserAccess.prototype =
try {
if (aOpener) {
newWindow = aOpener.top;
location = aOpener.location;
referrer =
Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(location, null, null);
if (aURI) {
location = aOpener.location;
referrer =
Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService)
.newURI(location, null, null);
newWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(nsIWebNavigation)
.loadURI(url, loadflags, referrer, null, null);
newWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(nsIWebNavigation)
.loadURI(aURI.spec, loadflags, referrer, null, null);
}
} else {
newWindow = gBrowser.selectedBrowser.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
getWebNavigation().loadURI(url, loadflags, null, null, null);
if (aURI) {
getWebNavigation().loadURI(aURI.spec, loadflags, null,
null, null);
}
}
if(!gPrefService.getBoolPref("browser.tabs.loadDivertedInBackground"))
content.focus();

View File

@ -40,7 +40,7 @@
interface nsIDOMWindow;
interface nsIURI;
[scriptable, uuid(af25c296-aaec-4f7f-8885-dd37a1cc0a13)]
[scriptable, uuid(f9691a49-7fb3-4b54-bb11-a4f2e0b6eddb)]
/**
* The C++ source has access to the browser script source through
@ -91,7 +91,10 @@ interface nsIBrowserDOMWindow : nsISupports
/**
* Load a URI
* @param aURI the URI to open. null is allowed; it means about:blank.
* @param aURI the URI to open. null is allowed. If null is passed in, no
* load will be done, though the window the load would have
* happened in will be returned.
* @param aWhere see possible values described above.
* @param aOpener window requesting the open (can be null).
* @param aContext the context in which the URI is being opened. This

View File

@ -877,10 +877,9 @@ nsContentTreeOwner::ProvideWindow(nsIDOMWindow* aParent,
}
*aWindowIsNew = (containerPref != nsIBrowserDOMWindow::OPEN_CURRENTWINDOW);
// Get a new rendering area from the browserDOMWin. To make this
// safe for cases when it'll try to return an existing window or
// something, get it with a null URI.
// Get a new rendering area from the browserDOMWin. We don't want
// to be starting any loads here, so get it with a null URI.
return browserDOMWin->OpenURI(nsnull, aParent, containerPref,
nsIBrowserDOMWindow::OPEN_NEW, aReturn);
}