2 * Test that session history's expiration tracker would remove bfcache on
6 // With bfcache not expired.
7 add_task(async function testValidCache() {
8 // Make an unrealistic large timeout.
9 await SpecialPowers.pushPrefEnv({
11 ["browser.sessionhistory.contentViewerTimeout", 86400],
12 // If Fission is disabled, the pref is no-op.
13 ["fission.bfcacheInParent", true],
17 await BrowserTestUtils.withNewTab(
18 { gBrowser, url: "data:text/html;charset=utf-8,pageA1" },
19 async function (browser) {
20 // Make a simple modification for bfcache testing.
21 await SpecialPowers.spawn(browser, [], () => {
22 content.document.body.textContent = "modified";
25 // Load a random page.
26 BrowserTestUtils.startLoadingURIString(
28 "data:text/html;charset=utf-8,pageA2"
30 await BrowserTestUtils.browserLoaded(browser);
32 // Go back and verify text content.
33 let awaitPageShow = BrowserTestUtils.waitForContentEvent(
39 await SpecialPowers.spawn(browser, [], () => {
40 is(content.document.body.textContent, "modified");
46 // With bfcache expired.
47 add_task(async function testExpiredCache() {
48 // Make bfcache timeout in 1 sec.
49 await SpecialPowers.pushPrefEnv({
51 ["browser.sessionhistory.contentViewerTimeout", 1],
52 // If Fission is disabled, the pref is no-op.
53 ["fission.bfcacheInParent", true],
57 await BrowserTestUtils.withNewTab(
58 { gBrowser, url: "data:text/html;charset=utf-8,pageB1" },
59 async function (browser) {
60 // Make a simple modification for bfcache testing.
61 await SpecialPowers.spawn(browser, [], () => {
62 content.document.body.textContent = "modified";
65 // Load a random page.
66 BrowserTestUtils.startLoadingURIString(
68 "data:text/html;charset=utf-8,pageB2"
70 await BrowserTestUtils.browserLoaded(browser);
72 // Wait for 3 times of expiration timeout, hopefully it's evicted...
73 await SpecialPowers.spawn(browser, [], () => {
74 return new Promise(resolve => {
75 content.setTimeout(resolve, 5000);
79 // Go back and verify text content.
80 let awaitPageShow = BrowserTestUtils.waitForContentEvent(
86 await SpecialPowers.spawn(browser, [], () => {
87 is(content.document.body.textContent, "pageB1");