diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 6bd07d1c943..c23720f7a2f 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -6345,9 +6345,6 @@ nsDocShell::InternalLoad(nsIURI * aURI, do_GetInterface(GetAsSupports(this)); NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE); - isNewWindow = PR_TRUE; - aFlags |= INTERNAL_LOAD_FLAGS_NEW_WINDOW; - nsDependentString name(aWindowTarget); nsCOMPtr newWin; rv = win->Open(EmptyString(), // URL to load @@ -6355,6 +6352,17 @@ nsDocShell::InternalLoad(nsIURI * aURI, EmptyString(), // Features getter_AddRefs(newWin)); + // In some cases the Open call doesn't actually result in a new + // window being opened (i.e. browser.link.open_newwindow is set + // to 1, forcing us to reuse the current window). This will + // protect us against that use case but still isn't totally + // ideal since perhaps in some future use case newWin could be + // some other, already open window. + if (win != newWin) { + isNewWindow = PR_TRUE; + aFlags |= INTERNAL_LOAD_FLAGS_NEW_WINDOW; + } + nsCOMPtr webNav = do_GetInterface(newWin); targetDocShell = do_QueryInterface(webNav);