Bug 544535 - Ignore push/replaceState's title argument. r=sicking, approval2.0=benjamin
authorJustin Lebar <justin.lebar@gmail.com>
Mon, 19 Jul 2010 14:46:01 -0700
changeset 48096 eb7798b88e813d5a0192588c2d602ae0eb03c576
parent 48095 3c5313a9c4370901793e5b4c9f04e82196e699e3
child 48097 fb854ad5a86b95855c69fc69f05c47574aef65dc
push id14570
push userjlebar@mozilla.com
push dateThu, 22 Jul 2010 20:44:12 +0000
treeherdermozilla-central@c20a6d551bbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs544535
milestone2.0b3pre
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 544535 - Ignore push/replaceState's title argument. r=sicking, approval2.0=benjamin
docshell/base/nsDocShell.cpp
dom/tests/mochitest/whatwg/test_bug500328.html
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -9214,30 +9214,31 @@ nsDocShell::AddState(nsIVariant *aData, 
     //        <fragment> components, raise a SECURITY_ERR and abort.
     // 3. If !aReplace:
     //     Remove from the session history all entries after the current entry,
     //     as we would after a regular navigation.
     // 4. As apropriate, either add a state object entry to the session history
     //    after the current entry with the following properties, or modify the
     //    current session history entry to set
     //      a. cloned data as the state object,
-    //      b. the given title as the title, and,
-    //      c. if the third argument was present, the absolute URL found in
+    //      b. if the third argument was present, the absolute URL found in
     //         step 2
     // 5. If aReplace is false (i.e. we're doing a pushState instead of a
     //    replaceState), notify bfcache that we've navigated to a new page.
     // 6. If the third argument is present, set the document's current address
     //    to the absolute URL found in step 2.
     //
     // It's important that this function not run arbitrary scripts after step 1
     // and before completing step 5.  For example, if a script called
     // history.back() before we completed step 5, bfcache might destroy an
     // active content viewer.  Since EvictContentViewers at the end of step 5
     // might run script, we can't just put a script blocker around the critical
     // section.
+    //
+    // Note that we completely ignore the aTitle parameter.
 
     nsresult rv;
 
     nsCOMPtr<nsIDocument> document = do_GetInterface(GetAsSupports(this));
     NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
 
     mLoadType = LOAD_PUSHSTATE;
 
@@ -9416,20 +9417,16 @@ nsDocShell::AddState(nsIVariant *aData, 
         document->SetDocumentURI(newURI);
 
         AddURIVisit(newURI, oldURI, oldURI, 0);
     }
     else {
         FireOnLocationChange(this, nsnull, mCurrentURI);
     }
 
-    // Try to set the title of the current history element
-    if (mOSHE)
-        mOSHE->SetTitle(aTitle);
-
     return NS_OK;
 }
 
 PRBool
 nsDocShell::ShouldAddToSessionHistory(nsIURI * aURI)
 {
     // I believe none of the about: urls should go in the history. But then
     // that could just be me... If the intent is only deny about:blank then we
--- a/dom/tests/mochitest/whatwg/test_bug500328.html
+++ b/dom/tests/mochitest/whatwg/test_bug500328.html
@@ -475,17 +475,21 @@ function runTest() {
   shistory = getSHistory(popup);
 
   enableChildPopStateCallback();
   yield;
   statusMsg("Awake after loading content into popup.");
 
   popup.history.replaceState({n:1, ok:true}, "state 1", "good1.html");
   locationEndsWith(popup, "good1.html");
-  is(getSHTitle(shistory), "state 1", "SHEntry title 'state 1'");
+
+  // Even though we replaceState with title "state 1", the title should remain
+  // "test 1" because we ignore the title argument in push/replaceState.  
+  // See bug 544535.
+  is(getSHTitle(shistory), "test 1", "SHEntry title 'state 1'");
 
   // Flush the event loop so our next load creates a new session history entry.
   shortWait();
   yield;
 
   enableChildPopStateCallback();
   popup.location = "file_bug500328_1.html";
   yield;