Bug 1689684 - Ensure docshell/test/browser/browser_bug1347823.js works with SHIP-BFCache, r=peterv
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 26 Mar 2021 19:15:02 +0000
changeset 640899 9bef0626ff2d9ae357a149cbc9c0cbaa64a18c0b
parent 640898 803f8bc9241ef13ffbc582a3f7f4c4089bef0fbe
child 640900 0b43c44aa242980a1ddffe37953383462f93cb71
push id15309
push userffxbld-merge
push dateMon, 19 Apr 2021 17:51:21 +0000
treeherdermozilla-beta@842785ce363f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1689684, 1347823
milestone89.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 1689684 - Ensure docshell/test/browser/browser_bug1347823.js works with SHIP-BFCache, r=peterv Depends on D109312 Differential Revision: https://phabricator.services.mozilla.com/D109313
docshell/shistory/nsSHistory.cpp
docshell/test/browser/browser.ini
docshell/test/browser/browser_bug1347823.js
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -271,17 +271,21 @@ nsSHistory::nsSHistory(BrowsingContext* 
   // target to the tabGroup.
   mHistoryTracker = mozilla::MakeUnique<HistoryTracker>(
       this,
       mozilla::Preferences::GetUint(CONTENT_VIEWER_TIMEOUT_SECONDS,
                                     CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT),
       GetCurrentSerialEventTarget());
 }
 
-nsSHistory::~nsSHistory() {}
+nsSHistory::~nsSHistory() {
+  // Clear mEntries explicitly here so that the destructor of the entries
+  // can still access nsSHistory in a reasonable way.
+  mEntries.Clear();
+}
 
 NS_IMPL_ADDREF(nsSHistory)
 NS_IMPL_RELEASE(nsSHistory)
 
 NS_INTERFACE_MAP_BEGIN(nsSHistory)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
   NS_INTERFACE_MAP_ENTRY(nsISHistory)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
@@ -1462,17 +1466,17 @@ class EntryAndDistance {
         mEntry(aEntry),
         mViewer(aEntry->GetContentViewer()),
         mLastTouched(mEntry->GetLastTouched()),
         mDistance(aDist) {
     nsCOMPtr<SessionHistoryEntry> she = do_QueryInterface(aEntry);
     if (she) {
       mFrameLoader = she->GetFrameLoader();
     }
-    NS_ASSERTION(mViewer || (mozilla::BFCacheInParent() && mFrameLoader),
+    NS_ASSERTION(mViewer || mFrameLoader,
                  "Entry should have a content viewer or frame loader.");
   }
 
   bool operator<(const EntryAndDistance& aOther) const {
     // Compare distances first, and fall back to last-accessed times.
     if (aOther.mDistance != this->mDistance) {
       return this->mDistance < aOther.mDistance;
     }
--- a/docshell/test/browser/browser.ini
+++ b/docshell/test/browser/browser.ini
@@ -88,17 +88,16 @@ skip-if =
 [browser_bug1543077-2.js]
 [browser_bug1543077-3.js]
 [browser_bug1543077-4.js]
 [browser_bug1594938.js]
 [browser_bug1206879.js]
 [browser_bug1309900_crossProcessHistoryNavigation.js]
 [browser_bug1328501.js]
 [browser_bug1347823.js]
-fail-if = sessionHistoryInParent
 [browser_bug134911.js]
 [browser_bug1415918_beforeunload_options.js]
 [browser_bug1622420.js]
 support-files =
   file_bug1622420.html
   Bug1622420Child.jsm
 [browser_bug1673702.js]
 skip-if =
--- a/docshell/test/browser/browser_bug1347823.js
+++ b/docshell/test/browser/browser_bug1347823.js
@@ -2,17 +2,21 @@
  * Test that session history's expiration tracker would remove bfcache on
  * expiration.
  */
 
 // With bfcache not expired.
 add_task(async function testValidCache() {
   // Make an unrealistic large timeout.
   await SpecialPowers.pushPrefEnv({
-    set: [["browser.sessionhistory.contentViewerTimeout", 86400]],
+    set: [
+      ["browser.sessionhistory.contentViewerTimeout", 86400],
+      // If Fission is disabled, the pref is no-op.
+      ["fission.bfcacheInParent", true],
+    ],
   });
 
   await BrowserTestUtils.withNewTab(
     { gBrowser, url: "data:text/html;charset=utf-8,pageA1" },
     async function(browser) {
       // Make a simple modification for bfcache testing.
       await SpecialPowers.spawn(browser, [], () => {
         content.document.body.textContent = "modified";
@@ -35,17 +39,21 @@ add_task(async function testValidCache()
     }
   );
 });
 
 // With bfcache expired.
 add_task(async function testExpiredCache() {
   // Make bfcache timeout in 1 sec.
   await SpecialPowers.pushPrefEnv({
-    set: [["browser.sessionhistory.contentViewerTimeout", 1]],
+    set: [
+      ["browser.sessionhistory.contentViewerTimeout", 1],
+      // If Fission is disabled, the pref is no-op.
+      ["fission.bfcacheInParent", true],
+    ],
   });
 
   await BrowserTestUtils.withNewTab(
     { gBrowser, url: "data:text/html;charset=utf-8,pageB1" },
     async function(browser) {
       // Make a simple modification for bfcache testing.
       await SpecialPowers.spawn(browser, [], () => {
         content.document.body.textContent = "modified";
@@ -53,17 +61,17 @@ add_task(async function testExpiredCache
 
       // Load a random page.
       BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,pageB2");
       await BrowserTestUtils.browserLoaded(browser);
 
       // Wait for 3 times of expiration timeout, hopefully it's evicted...
       await SpecialPowers.spawn(browser, [], () => {
         return new Promise(resolve => {
-          content.setTimeout(resolve, 3000);
+          content.setTimeout(resolve, 5000);
         });
       });
 
       // Go back and verify text content.
       let awaitPageShow = BrowserTestUtils.waitForContentEvent(
         browser,
         "pageshow"
       );