browser_label_and_icon.js (1788B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_setup(async function () { 7 await SpecialPowers.pushPrefEnv({ 8 set: [["test.wait300msAfterTabSwitch", true]], 9 }); 10 }); 11 12 /** 13 * Ensure that a pending tab has label and icon correctly set. 14 */ 15 add_task(async function test_label_and_icon() { 16 // Make sure that tabs are restored on demand as otherwise the tab will start 17 // loading immediately and we can't check its icon and label. 18 await SpecialPowers.pushPrefEnv({ 19 set: [ 20 ["browser.sessionstore.restore_on_demand", true], 21 ["browser.urlbar.scotchBonnet.enableOverride", false], 22 ], 23 }); 24 25 // Create a new tab. 26 let tab = BrowserTestUtils.addTab(gBrowser, "about:robots"); 27 let browser = tab.linkedBrowser; 28 await promiseBrowserLoaded(browser); 29 // Because there is debounce logic in FaviconLoader.sys.mjs to reduce the 30 // favicon loads, we have to wait some time before checking that icon was 31 // stored properly. 32 await BrowserTestUtils.waitForCondition( 33 () => { 34 return gBrowser.getIcon(tab) != null; 35 }, 36 "wait for favicon load to finish", 37 100, 38 5 39 ); 40 41 // Retrieve the tab state. 42 await TabStateFlusher.flush(browser); 43 let state = ss.getTabState(tab); 44 BrowserTestUtils.removeTab(tab); 45 browser = null; 46 47 // Open a new tab to restore into. 48 tab = BrowserTestUtils.addTab(gBrowser, "about:blank"); 49 ss.setTabState(tab, state); 50 await promiseTabRestoring(tab); 51 52 // Check that label and icon are set for the restoring tab. 53 is( 54 gBrowser.getIcon(tab), 55 "chrome://browser/content/robot.ico", 56 "icon is set" 57 ); 58 is(tab.label, "Gort! Klaatu barada nikto!", "label is set"); 59 60 // Cleanup. 61 BrowserTestUtils.removeTab(tab); 62 });