browser_current_entry_always_in_history_menu.js (1388B)
1 "use strict"; 2 3 const TEST_URI = "https://example.com/"; 4 5 add_setup(async function () { 6 await SpecialPowers.pushPrefEnv({ 7 set: [["browser.navigation.requireUserInteraction", true]], 8 }); 9 }); 10 11 add_task(async () => { 12 await BrowserTestUtils.withNewTab(TEST_URI, async browser => { 13 // Navigate away, after causing a user interaction. 14 await SpecialPowers.spawn(browser, [], async () => { 15 content.document.notifyUserGestureActivation(); 16 }); 17 await followLink(TEST_URI + "2.html"); 18 19 // Navigate again, without causing a user interaction. 20 let loaded = BrowserTestUtils.waitForLocationChange( 21 gBrowser, 22 TEST_URI + "3.html" 23 ); 24 await SpecialPowers.spawn(browser, [], async () => { 25 content.history.pushState({}, "", "https://example.com/3.html"); 26 }); 27 await loaded; 28 29 // The entry with no interaction shouldn't appear. 30 await assertMenulist([TEST_URI + "3.html", TEST_URI]); 31 32 // Go back using history.back, which does not check for user interaction. 33 loaded = BrowserTestUtils.waitForLocationChange( 34 gBrowser, 35 TEST_URI + "2.html" 36 ); 37 await SpecialPowers.spawn(browser, [], async () => { 38 content.history.back(); 39 }); 40 await loaded; 41 42 // We are back on entry 2, so it should appear in the list. 43 await assertMenulist([TEST_URI + "3.html", TEST_URI + "2.html", TEST_URI]); 44 }); 45 });