browser_page_style_menu_update.js (1432B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const PAGE = WEB_ROOT + "page_style_sample.html"; 7 8 /** 9 * Tests that the Page Style menu shows the currently 10 * selected Page Style after a new one has been selected. 11 */ 12 add_task(async function () { 13 let tab = await BrowserTestUtils.openNewForegroundTab( 14 gBrowser, 15 "about:blank", 16 false 17 ); 18 let browser = tab.linkedBrowser; 19 BrowserTestUtils.startLoadingURIString(browser, PAGE); 20 await promiseStylesheetsLoaded(browser, 18); 21 22 let menupopup = document.getElementById("pageStyleMenu").menupopup; 23 gPageStyleMenu.fillPopup(menupopup); 24 25 // page_style_sample.html should default us to selecting the stylesheet 26 // with the title "6" first. 27 let selected = menupopup.querySelector("menuitem[checked]"); 28 is( 29 selected.getAttribute("label"), 30 "6", 31 "Should have '6' stylesheet selected by default" 32 ); 33 34 // Now select stylesheet "1" 35 let target = menupopup.querySelector("menuitem[label='1']"); 36 target.doCommand(); 37 38 gPageStyleMenu.fillPopup(menupopup); 39 // gPageStyleMenu empties out the menu between opens, so we need 40 // to get a new reference to the selected menuitem 41 selected = menupopup.querySelector("menuitem[checked]"); 42 is( 43 selected.getAttribute("label"), 44 "1", 45 "Should now have stylesheet 1 selected" 46 ); 47 48 BrowserTestUtils.removeTab(tab); 49 });