Bug 1003100 - pushState() in iframe fails when reloading with CTRL+F5, r=bz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 16 Oct 2015 20:05:54 +0300
changeset 301482 4f4e54b55fc8e048f0a0a4d882c45f02bdab99f9
parent 301481 cb5785379a0b33f9a825a01e7236baf239f2fcdc
child 301483 d922e18b6dc14b44bc3775e14905f319dc35f7be
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1003100
milestone44.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 1003100 - pushState() in iframe fails when reloading with CTRL+F5, r=bz
docshell/base/nsDocShell.cpp
docshell/test/navigation/file_shiftReload_and_pushState.html
docshell/test/navigation/mochitest.ini
docshell/test/navigation/test_sessionhistory.html
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -11116,18 +11116,21 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsICh
     }
   }
 
   // Determine if this type of load should update history.
   bool updateGHistory = !(aLoadType == LOAD_BYPASS_HISTORY ||
                           aLoadType == LOAD_ERROR_PAGE ||
                           aLoadType & LOAD_CMD_HISTORY);
 
-  // We don't update session history on reload.
-  bool updateSHistory = updateGHistory && (!(aLoadType & LOAD_CMD_RELOAD));
+  // We don't update session history on reload unless we're loading
+  // an iframe in shift-reload case.
+  bool updateSHistory = updateGHistory &&
+                        (!(aLoadType & LOAD_CMD_RELOAD) ||
+                         (IsForceReloadType(aLoadType) && IsFrame()));
 
   // Create SH Entry (mLSHE) only if there is a SessionHistory object in the
   // current frame or in the root docshell.
   nsCOMPtr<nsISHistory> rootSH = mSessionHistory;
   if (!rootSH) {
     // Get the handle to SH from the root docshell
     GetRootSessionHistory(getter_AddRefs(rootSH));
     if (!rootSH) {
@@ -11190,19 +11193,19 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsICh
     SetHistoryEntry(&mLSHE, mOSHE);
   }
 
   /* If the user pressed shift-reload, cache will create a new cache key
    * for the page. Save the new cacheKey in Session History.
    * see bug 90098
    */
   if (aChannel && IsForceReloadType(aLoadType)) {
-    NS_ASSERTION(!updateSHistory,
-                 "We shouldn't be updating session history for forced"
-                 " reloads!");
+    MOZ_ASSERT(!updateSHistory || IsFrame(),
+               "We shouldn't be updating session history for forced"
+               " reloads unless we're in a newly created iframe!");
 
     nsCOMPtr<nsICacheInfoChannel> cacheChannel(do_QueryInterface(aChannel));
     nsCOMPtr<nsISupports> cacheKey;
     // Get the Cache Key and store it in SH.
     if (cacheChannel) {
       cacheChannel->GetCacheKey(getter_AddRefs(cacheKey));
     }
     // If we already have a loading history entry, store the new cache key
new file mode 100644
--- /dev/null
+++ b/docshell/test/navigation/file_shiftReload_and_pushState.html
@@ -0,0 +1,29 @@
+<html>
+  <head>
+    <script>
+      function test() {
+        try {
+          frames[0].history.pushState({}, "state", "?pushed");
+        } catch(ex) {
+          opener.ok(false, "history.pushState shouldn't throw");
+        }
+
+        if (!opener.shiftReloadPushStateFirstRound) {
+          opener.shiftReloadPushStateFirstRound = true;
+          window.location.reload(true);
+        } else {
+          opener.ok(true, "Did run history.push");
+          opener.nextTest();
+          window.close();
+        }
+      }
+
+      window.addEventListener("load", function() { setTimeout(test, 0); });
+    </script>
+  </head>
+  <body>
+  <iframe src="frame0.html"></iframe>
+  <script>
+  </script>
+  </body>
+</html>
--- a/docshell/test/navigation/mochitest.ini
+++ b/docshell/test/navigation/mochitest.ini
@@ -5,16 +5,17 @@ support-files =
   file_bug462076_1.html
   file_bug462076_2.html
   file_bug462076_3.html
   file_bug508537_1.html
   file_bug534178.html
   file_document_write_1.html
   file_fragment_handling_during_load.html
   file_nested_frames.html
+  file_shiftReload_and_pushState.html
   file_static_and_dynamic_1.html
   frame0.html
   frame1.html
   frame2.html
   frame3.html
   goback.html
   iframe.html
   navigate.html
--- a/docshell/test/navigation/test_sessionhistory.html
+++ b/docshell/test/navigation/test_sessionhistory.html
@@ -23,17 +23,18 @@ var testFiles =
   [ "file_bug462076_1.html",         // Dynamic frames before onload
     "file_bug462076_2.html",         // Dynamic frames when handling onload
     "file_bug462076_3.html",         // Dynamic frames after onload
     "file_bug508537_1.html",         // Dynamic frames and forward-back
     "file_document_write_1.html",    // Session history + document.write
     //"file_static_and_dynamic_1.html",// Static and dynamic frames and forward-back
     "file_bug534178.html",           // Session history transaction clean-up.
     "file_fragment_handling_during_load.html",
-    "file_nested_frames.html"
+    "file_nested_frames.html",
+    "file_shiftReload_and_pushState.html"
   ];
 var testCount = 0; // Used by the test files.
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
 var testWindow;
 function nextTest_() {