diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 30f8e516c391..a801bd8cb549 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -258,7 +258,7 @@ NS_INTERFACE_MAP_END_THREADSAFE //***************************************************************************** NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink) { - NS_ENSURE_ARG_POINTER(aSink); + NS_ENSURE_ARG_POINTER(aSink); if (aIID.Equals(NS_GET_IID(nsIURIContentListener)) && NS_SUCCEEDED(EnsureContentListener())) { @@ -5115,12 +5115,44 @@ void nsDocShell::SetCurrentURI(nsIURI * aURI) { mCurrentURI = aURI; //This assignment addrefs + PRBool isRoot = PR_FALSE; // Is this the root docshell + PRBool isSubFrame=PR_FALSE; // Is this a subframe navigation? - nsCOMPtr loader(do_GetInterface(mLoadCookie)); + if (!mLoadCookie) + return; + + nsCOMPtr loader(do_GetInterface(mLoadCookie)); + nsCOMPtr webProgress(do_QueryInterface(mLoadCookie)); + nsCOMPtr root; + + GetSameTypeRootTreeItem(getter_AddRefs(root)); + if (root.get() == NS_STATIC_CAST(nsIDocShellTreeItem *, this)) + { + // This is the root docshell + isRoot = PR_TRUE; + } + if (LSHE) { + nsCOMPtr historyEntry(do_QueryInterface(LSHE)); + + // Check if this is a subframe navigation + if (historyEntry) { + historyEntry->GetIsSubFrame(&isSubFrame); + } + } + + if (!isSubFrame && !isRoot) { + /* + * We don't want to send OnLocationChange notifications when + * a subframe is being loaded for the first time, while + * visiting a frameset page + */ + return; + } + NS_ASSERTION(loader, "No document loader"); if (loader) { - loader->FireOnLocationChange(nsnull, nsnull, aURI); + loader->FireOnLocationChange(webProgress, nsnull, aURI); } } diff --git a/xpfe/browser/resources/content/nsBrowserStatusHandler.js b/xpfe/browser/resources/content/nsBrowserStatusHandler.js index 1de18e931a6f..82b8f814355c 100644 --- a/xpfe/browser/resources/content/nsBrowserStatusHandler.js +++ b/xpfe/browser/resources/content/nsBrowserStatusHandler.js @@ -232,6 +232,7 @@ nsBrowserStatusHandler.prototype = onLocationChange : function(aWebProgress, aRequest, aLocation) { var location = aLocation.spec; + domWindow = aWebProgress.DOMWindow; if (this.hideAboutBlank) { this.hideAboutBlank = false; @@ -241,9 +242,12 @@ nsBrowserStatusHandler.prototype = // We should probably not do this if the value has changed since the user // searched - this.urlBar.value = location; - SetPageProxyState("valid"); - + // Update urlbar only if a new page was loaded on the primary content area + // Do not update urlbar if there was a subframe navigation + if (domWindow == domWindow.top) { + this.urlBar.value = location; + SetPageProxyState("valid"); + } UpdateBackForwardButtons(); },