browser_switch_to_customize_mode.js (1903B)
1 "use strict"; 2 3 function isMenubarVisible() { 4 return BrowserTestUtils.isVisible(document.getElementById("toolbar-menubar")); 5 } 6 7 add_task(async function () { 8 let menubarVisible = isMenubarVisible(); 9 10 await startCustomizing(); 11 is(gBrowser.tabs.length, 2, "Should have 2 tabs"); 12 13 is( 14 isMenubarVisible(), 15 menubarVisible, 16 "Menubar visibility shouldn't change during customize mode" 17 ); 18 19 let paletteKidCount = document.getElementById( 20 "customization-palette" 21 ).childElementCount; 22 let nonCustomizingTab = gBrowser.tabContainer.querySelector( 23 "tab:not([customizemode=true])" 24 ); 25 let finishedCustomizing = BrowserTestUtils.waitForEvent( 26 gNavToolbox, 27 "aftercustomization" 28 ); 29 await BrowserTestUtils.switchTab(gBrowser, nonCustomizingTab); 30 await finishedCustomizing; 31 32 let startedCount = 0; 33 let handler = () => startedCount++; 34 gNavToolbox.addEventListener("customizationstarting", handler); 35 await startCustomizing(); 36 CustomizableUI.removeWidgetFromArea("stop-reload-button"); 37 await gCustomizeMode.reset().catch(e => { 38 ok( 39 false, 40 "Threw an exception trying to reset after making modifications in customize mode: " + 41 e 42 ); 43 }); 44 45 let newKidCount = document.getElementById( 46 "customization-palette" 47 ).childElementCount; 48 is( 49 newKidCount, 50 paletteKidCount, 51 "Should have just as many items in the palette as before." 52 ); 53 await endCustomizing(); 54 55 is( 56 isMenubarVisible(), 57 menubarVisible, 58 "Menubar visibility shouldn't change exiting customize mode" 59 ); 60 is(startedCount, 1, "Should have only started once"); 61 gNavToolbox.removeEventListener("customizationstarting", handler); 62 let toolbars = document.querySelectorAll("toolbar"); 63 for (let toolbar of toolbars) { 64 ok( 65 !toolbar.hasAttribute("customizing"), 66 "Toolbar " + toolbar.id + " is no longer customizing" 67 ); 68 } 69 });