browser_bug1798780.js (1604B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // The test loads an initial page and then another page which does enough 7 // fragment navigations so that when going back to the initial page and then 8 // forward to the last page, the initial page is evicted from the bfcache. 9 add_task(async function testBFCacheEviction() { 10 // Make an unrealistic large timeout. 11 await SpecialPowers.pushPrefEnv({ 12 set: [["browser.sessionhistory.contentViewerTimeout", 86400]], 13 }); 14 15 const uri = "data:text/html,initial page"; 16 const uri2 = 17 getRootDirectory(gTestPath).replace( 18 "chrome://mochitests/content", 19 "https://example.com" 20 ) + "dummy_page.html"; 21 22 await BrowserTestUtils.withNewTab( 23 { gBrowser, url: uri }, 24 async function (browser) { 25 BrowserTestUtils.startLoadingURIString(browser, uri2); 26 await BrowserTestUtils.browserLoaded(browser); 27 28 let awaitPageShow = BrowserTestUtils.waitForContentEvent( 29 browser, 30 "pageshow" 31 ); 32 await SpecialPowers.spawn(browser, [], async function () { 33 content.location.hash = "1"; 34 content.location.hash = "2"; 35 content.location.hash = "3"; 36 content.history.go(-4); 37 }); 38 39 await awaitPageShow; 40 41 let awaitPageShow2 = BrowserTestUtils.waitForContentEvent( 42 browser, 43 "pageshow" 44 ); 45 await SpecialPowers.spawn(browser, [], async function () { 46 content.history.go(4); 47 }); 48 await awaitPageShow2; 49 ok(true, "Didn't time out."); 50 } 51 ); 52 });