browser_dbg-keyboard-shortcuts-modal.js (1294B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 /** 6 * Test the keyboard shortcuts modal 7 */ 8 9 "use strict"; 10 11 add_task(async function () { 12 const dbg = await initDebuggerWithAbsoluteURL( 13 "data:text/html,Test keyboard shortcuts modal" 14 ); 15 16 ok(!getShortcutsModal(dbg), "The shortcuts modal is hidden by default"); 17 18 info("Open the modal with the shortcut"); 19 pressKeyboardShortcut(dbg); 20 21 const el = await waitFor(() => getShortcutsModal(dbg)); 22 const sections = [...el.querySelectorAll(".shortcuts-section h2")].map( 23 h2 => h2.textContent 24 ); 25 is( 26 JSON.stringify(sections), 27 JSON.stringify(["Editor", "Stepping", "Search"]), 28 "The modal has the expected sections" 29 ); 30 31 info("Close the modal with the shortcut"); 32 pressKeyboardShortcut(dbg); 33 await waitFor(() => !getShortcutsModal(dbg)); 34 ok(true, "The modal was closed"); 35 }); 36 37 function getShortcutsModal(dbg) { 38 return findElementWithSelector(dbg, ".shortcuts-modal"); 39 } 40 41 function pressKeyboardShortcut(dbg) { 42 EventUtils.synthesizeKey( 43 "/", 44 { 45 [Services.appinfo.OS === "Darwin" ? "metaKey" : "ctrlKey"]: true, 46 }, 47 dbg.win 48 ); 49 }