browser_unrestored_crashedTabs.js (2460B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests that if we have tabs that are still in the "click to 8 * restore" state, that if their browsers crash, that we don't 9 * show the crashed state for those tabs (since selecting them 10 * should restore them anyway). 11 */ 12 13 const PREF = "browser.sessionstore.restore_on_demand"; 14 const PAGE = 15 "data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page."; 16 17 add_task(async function test() { 18 await pushPrefs([PREF, true]); 19 20 await BrowserTestUtils.withNewTab( 21 { 22 gBrowser, 23 url: PAGE, 24 }, 25 async function (browser) { 26 await TabStateFlusher.flush(browser); 27 28 // We'll create a second "pending" tab. This is the one we'll 29 // ensure doesn't go to about:tabcrashed. We start it non-remote 30 // since this is how SessionStore creates all browsers before 31 // they are restored. 32 let unrestoredTab = BrowserTestUtils.addTab(gBrowser, "about:blank", { 33 skipAnimation: true, 34 forceNotRemote: true, 35 }); 36 37 let state = { 38 entries: [{ url: PAGE, triggeringPrincipal_base64 }], 39 }; 40 41 ss.setTabState(unrestoredTab, JSON.stringify(state)); 42 43 ok(!unrestoredTab.hasAttribute("crashed"), "tab is not crashed"); 44 ok(unrestoredTab.hasAttribute("pending"), "tab is pending"); 45 46 // Now crash the selected browser. 47 await BrowserTestUtils.crashFrame(browser); 48 49 ok(!unrestoredTab.hasAttribute("crashed"), "tab is still not crashed"); 50 ok(unrestoredTab.hasAttribute("pending"), "tab is still pending"); 51 52 // Selecting the tab should now restore it. 53 gBrowser.selectedTab = unrestoredTab; 54 await promiseTabRestored(unrestoredTab); 55 56 ok(!unrestoredTab.hasAttribute("crashed"), "tab is still not crashed"); 57 ok(!unrestoredTab.hasAttribute("pending"), "tab is no longer pending"); 58 59 // The original tab should still be crashed 60 let originalTab = gBrowser.getTabForBrowser(browser); 61 ok(originalTab.hasAttribute("crashed"), "original tab is crashed"); 62 ok(!originalTab.isRemoteBrowser, "Should not be remote"); 63 64 // We'd better be able to restore it still. 65 gBrowser.selectedTab = originalTab; 66 SessionStore.reviveCrashedTab(originalTab); 67 await promiseTabRestored(originalTab); 68 69 // Clean up. 70 BrowserTestUtils.removeTab(unrestoredTab); 71 } 72 ); 73 });