Bug 1170488 - Document URI should be updated before sending out onLocationChange. r=smaug
authorMike Conley <mconley@mozilla.com>
Wed, 17 Jun 2015 10:26:28 -0400
changeset 249540 53d80bc541e2f1829865807e3a3c6768942f4b82
parent 249539 13e422276d7ceef053407bde7a13b9fc0339c11e
child 249541 8eb956e0ce98d86a9df7c8ef63177b532e75202e
push id61281
push usermconley@mozilla.com
push dateThu, 18 Jun 2015 13:41:35 +0000
treeherdermozilla-inbound@8eb956e0ce98 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1170488
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1170488 - Document URI should be updated before sending out onLocationChange. r=smaug
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10089,16 +10089,21 @@ nsDocShell::InternalLoad(nsIURI* aURI,
 
       /* we need to assign mLSHE to aSHEntry right here, so that on History
        * loads, SetCurrentURI() called from OnNewURI() will send proper
        * onLocationChange() notifications to the browser to update
        * back/forward buttons.
        */
       SetHistoryEntry(&mLSHE, aSHEntry);
 
+      // Set the doc's URI according to the new history entry's URI.
+      nsCOMPtr<nsIDocument> doc = GetDocument();
+      NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
+      doc->SetDocumentURI(aURI);
+
       /* This is a anchor traversal with in the same page.
        * call OnNewURI() so that, this traversal will be
        * recorded in session and global history.
        */
       nsCOMPtr<nsISupports> owner;
       if (mOSHE) {
         mOSHE->GetOwner(getter_AddRefs(owner));
       }
@@ -10179,21 +10184,16 @@ nsDocShell::InternalLoad(nsIURI* aURI,
         nsCOMPtr<IHistory> history = services::GetHistoryService();
         if (history) {
           history->SetURITitle(aURI, mTitle);
         } else if (mGlobalHistory) {
           mGlobalHistory->SetPageTitle(aURI, mTitle);
         }
       }
 
-      // Set the doc's URI according to the new history entry's URI.
-      nsCOMPtr<nsIDocument> doc = GetDocument();
-      NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
-      doc->SetDocumentURI(aURI);
-
       SetDocCurrentStateObj(mOSHE);
 
       // Inform the favicon service that the favicon for oldURI also
       // applies to aURI.
       CopyFavicon(currentURI, aURI, mInPrivateBrowsing);
 
       nsRefPtr<nsGlobalWindow> win = mScriptGlobal ?
         mScriptGlobal->GetCurrentInnerWindowInternal() : nullptr;
@@ -11711,18 +11711,18 @@ nsDocShell::AddState(JS::Handle<JS::Valu
   // since SetCurrentURI will call FireOnLocationChange for us.
   //
   // Both SetCurrentURI(...) and FireDummyOnLocationChange() pass
   // nullptr for aRequest param to FireOnLocationChange(...). Such an update
   // notification is allowed only when we know docshell is not loading a new
   // document and it requires LOCATION_CHANGE_SAME_DOCUMENT flag. Otherwise,
   // FireOnLocationChange(...) breaks security UI.
   if (!equalURIs) {
+    document->SetDocumentURI(newURI);
     SetCurrentURI(newURI, nullptr, true, LOCATION_CHANGE_SAME_DOCUMENT);
-    document->SetDocumentURI(newURI);
 
     AddURIVisit(newURI, oldURI, oldURI, 0);
 
     // AddURIVisit doesn't set the title for the new URI in global history,
     // so do that here.
     if (mUseGlobalHistory && !mInPrivateBrowsing) {
       nsCOMPtr<IHistory> history = services::GetHistoryService();
       if (history) {