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({
10 set: [["browser.sessionhistory.contentViewerTimeout", 86400]],
13 await BrowserTestUtils.withNewTab(
14 { gBrowser, url: "data:text/html;charset=utf-8,page1" },
15 async function(browser) {
16 // Make a simple modification for bfcache testing.
17 await SpecialPowers.spawn(browser, [], () => {
18 content.document.body.textContent = "modified";
21 // Load a random page.
22 BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,page2");
23 await BrowserTestUtils.browserLoaded(browser);
25 // Go back and verify text content.
26 let awaitPageShow = BrowserTestUtils.waitForContentEvent(
32 await SpecialPowers.spawn(browser, [], () => {
33 is(content.document.body.textContent, "modified");
39 // With bfcache expired.
40 add_task(async function testExpiredCache() {
41 // Make bfcache timeout in 1 sec.
42 await SpecialPowers.pushPrefEnv({
43 set: [["browser.sessionhistory.contentViewerTimeout", 1]],
46 await BrowserTestUtils.withNewTab(
47 { gBrowser, url: "data:text/html;charset=utf-8,page1" },
48 async function(browser) {
49 // Make a simple modification for bfcache testing.
50 await SpecialPowers.spawn(browser, [], () => {
51 content.document.body.textContent = "modified";
54 // Load a random page.
55 BrowserTestUtils.loadURI(browser, "data:text/html;charset=utf-8,page2");
56 await BrowserTestUtils.browserLoaded(browser);
58 // Wait for 3 times of expiration timeout, hopefully it's evicted...
59 await SpecialPowers.spawn(browser, [], () => {
60 return new Promise(resolve => {
61 content.setTimeout(resolve, 3000);
65 // Go back and verify text content.
66 let awaitPageShow = BrowserTestUtils.waitForContentEvent(
72 await SpecialPowers.spawn(browser, [], () => {
73 is(content.document.body.textContent, "page1");