browser_dbg-keyboard-navigation.js (1525B)
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 // Tests that keyboard navigation into and out of debugger code editor 6 7 "use strict"; 8 9 add_task(async function () { 10 const dbg = await initDebugger("doc-scripts.html", "simple2.js"); 11 const doc = dbg.win.document; 12 13 const focusableEditorElementSelector = ".cm-content"; 14 await selectSource(dbg, "simple2.js"); 15 16 const focusableEditorElement = await waitForElementWithSelector( 17 dbg, 18 focusableEditorElementSelector 19 ); 20 21 info("Focus on the editor"); 22 focusableEditorElement.focus(); 23 24 is(doc.activeElement, focusableEditorElement, "Editor is focused"); 25 26 info( 27 "Press shift + tab to navigate out of the editor to the previous tab element" 28 ); 29 pressKey(dbg, "ShiftTab"); 30 31 is( 32 doc.activeElement.className, 33 findElementWithSelector(dbg, ".cm6-dt-foldgutter__toggle-button").className, 34 "The left sidebar toggle button is focused" 35 ); 36 37 info("Press tab to navigate back to the editor"); 38 pressKey(dbg, "Tab"); 39 40 is( 41 findElementWithSelector(dbg, focusableEditorElementSelector), 42 doc.activeElement, 43 "Editor is focused again" 44 ); 45 46 info("Press tab again to navigate out of the editor to the next tab element"); 47 pressKey(dbg, "Tab"); 48 49 is( 50 findElementWithSelector(dbg, ".action.black-box"), 51 doc.activeElement, 52 "The ignore source button is focused" 53 ); 54 });