browser_menubar_visibility.js (1710B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check that menubar visibility is propagated correctly to new windows. 8 */ 9 add_task(async function test_menubar_visbility() { 10 let menubar = document.getElementById("toolbar-menubar"); 11 ok(menubar.hasAttribute("autohide"), "Menubar should be autohiding"); 12 registerCleanupFunction(() => { 13 Services.xulStore.removeValue( 14 AppConstants.BROWSER_CHROME_URL, 15 menubar.id, 16 "autohide" 17 ); 18 menubar.setAttribute("autohide", "true"); 19 }); 20 21 let contextMenu = document.getElementById("toolbar-context-menu"); 22 let shownPromise = popupShown(contextMenu); 23 EventUtils.synthesizeMouse( 24 document.getElementById("stop-reload-button"), 25 2, 26 2, 27 { 28 type: "contextmenu", 29 button: 2, 30 } 31 ); 32 await shownPromise; 33 let attrChanged = BrowserTestUtils.waitForAttributeRemoval( 34 "autohide", 35 menubar 36 ); 37 EventUtils.synthesizeMouseAtCenter( 38 document.getElementById("toggle_toolbar-menubar"), 39 {} 40 ); 41 await attrChanged; 42 contextMenu.hidePopup(); // to be safe. 43 44 ok( 45 !menubar.hasAttribute("autohide"), 46 "Menubar should now be permanently visible." 47 ); 48 let persistedValue = Services.xulStore.getValue( 49 AppConstants.BROWSER_CHROME_URL, 50 menubar.id, 51 "autohide" 52 ); 53 is(persistedValue, "-moz-missing\n", "New value should be persisted"); 54 55 let win = await BrowserTestUtils.openNewBrowserWindow(); 56 57 ok( 58 !win.document.getElementById("toolbar-menubar").hasAttribute("autohide"), 59 "Menubar should also be permanently visible in the new window." 60 ); 61 62 await BrowserTestUtils.closeWindow(win); 63 });