From 3b790f63018cfabc4dae274223baa6649df39d63 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Tue, 25 Jan 2022 11:13:12 +0000 Subject: [PATCH] Bug 1719178 - test, r=peterv Depends on D119114 Differential Revision: https://phabricator.services.mozilla.com/D119303 --- docshell/test/browser/browser.ini | 1 + docshell/test/browser/browser_bug1719178.js | 34 +++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 docshell/test/browser/browser_bug1719178.js diff --git a/docshell/test/browser/browser.ini b/docshell/test/browser/browser.ini index 58e561406523..a2b9c0538144 100644 --- a/docshell/test/browser/browser.ini +++ b/docshell/test/browser/browser.ini @@ -116,6 +116,7 @@ support-files = [browser_bug1674464.js] https_first_disabled = true skip-if = !fission || !crashreporter # On a crash we only keep history when fission is enabled. +[browser_bug1719178.js] [browser_bug234628-1.js] [browser_bug234628-10.js] [browser_bug234628-11.js] diff --git a/docshell/test/browser/browser_bug1719178.js b/docshell/test/browser/browser_bug1719178.js new file mode 100644 index 000000000000..ec42ec79d5cd --- /dev/null +++ b/docshell/test/browser/browser_bug1719178.js @@ -0,0 +1,34 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; +SimpleTest.requestFlakyTimeout( + "The test needs to let objects die asynchronously." +); + +add_task(async function test_accessing_shistory() { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:preferences" + ); + let sh = tab.linkedBrowser.browsingContext.sessionHistory; + ok(sh, "Should have SessionHistory object"); + gBrowser.removeTab(tab); + tab = null; + for (let i = 0; i < 5; ++i) { + SpecialPowers.Services.obs.notifyObservers( + null, + "memory-pressure", + "heap-minimize" + ); + SpecialPowers.DOMWindowUtils.garbageCollect(); + await new Promise(function(r) { + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout + setTimeout(r, 50); + }); + } + + try { + sh.reloadCurrentEntry(); + } catch (ex) {} + ok(true, "This test shouldn't crash."); +});