browser_inspector_highlighter-keybinding_01.js (2205B)
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 "use strict"; 6 7 // Test that the keybindings for Picker work alright 8 9 const TEST_URL = URL_ROOT + "doc_inspector_highlighter_dom.html"; 10 11 add_task(async function () { 12 const { inspector, toolbox, highlighterTestFront } = 13 await openInspectorForURL(TEST_URL); 14 const { waitForHighlighterTypeShown } = getHighlighterTestHelpers(inspector); 15 16 await startPicker(toolbox); 17 18 info("Selecting the simple-div1 DIV"); 19 await hoverElement(inspector, "#simple-div1"); 20 21 ok( 22 await highlighterTestFront.assertHighlightedNode("#simple-div1"), 23 "The highlighter shows #simple-div1. OK." 24 ); 25 26 // First Child selection 27 info("Testing first-child selection."); 28 29 await doKeyHover("VK_RIGHT"); 30 ok( 31 await highlighterTestFront.assertHighlightedNode("#useless-para"), 32 "The highlighter shows #useless-para. OK." 33 ); 34 35 info("Selecting the useful-para paragraph DIV"); 36 await hoverElement(inspector, "#useful-para"); 37 ok( 38 await highlighterTestFront.assertHighlightedNode("#useful-para"), 39 "The highlighter shows #useful-para. OK." 40 ); 41 42 await doKeyHover("VK_RIGHT"); 43 ok( 44 await highlighterTestFront.assertHighlightedNode("#bold"), 45 "The highlighter shows #bold. OK." 46 ); 47 48 info("Going back up to the simple-div1 DIV"); 49 await doKeyHover("VK_LEFT"); 50 await doKeyHover("VK_LEFT"); 51 ok( 52 await highlighterTestFront.assertHighlightedNode("#simple-div1"), 53 "The highlighter shows #simple-div1. OK." 54 ); 55 56 info("First child selection test Passed."); 57 58 info("Stopping the picker"); 59 await toolbox.nodePicker.stop({ canceled: true }); 60 61 function doKeyHover(key) { 62 info("Key pressed. Waiting for element to be highlighted/hovered"); 63 const onPickerHovered = toolbox.nodePicker.once("picker-node-hovered"); 64 const onHighlighterShown = waitForHighlighterTypeShown( 65 inspector.highlighters.TYPES.BOXMODEL 66 ); 67 BrowserTestUtils.synthesizeKey(key, {}, gBrowser.selectedBrowser); 68 69 return Promise.all([onPickerHovered, onHighlighterShown]); 70 } 71 });