browser_inspector_highlighter-keybinding_02.js (2045B)
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 // Previously chosen child memory 19 info("Testing whether previously chosen child is remembered"); 20 21 info("Selecting the ahoy paragraph DIV"); 22 await hoverElement(inspector, "#ahoy"); 23 24 await doKeyHover("VK_LEFT"); 25 ok( 26 await highlighterTestFront.assertHighlightedNode("#simple-div2"), 27 "The highlighter shows #simple-div2. OK." 28 ); 29 30 await doKeyHover("VK_RIGHT"); 31 ok( 32 await highlighterTestFront.assertHighlightedNode("#ahoy"), 33 "The highlighter shows #ahoy. OK." 34 ); 35 36 info("Going back up to the complex-div DIV"); 37 await doKeyHover("VK_LEFT"); 38 await doKeyHover("VK_LEFT"); 39 ok( 40 await highlighterTestFront.assertHighlightedNode("#complex-div"), 41 "The highlighter shows #complex-div. OK." 42 ); 43 44 await doKeyHover("VK_RIGHT"); 45 ok( 46 await highlighterTestFront.assertHighlightedNode("#simple-div2"), 47 "The highlighter shows #simple-div2. OK." 48 ); 49 50 info("Previously chosen child is remembered. Passed."); 51 52 info("Stopping the picker"); 53 await toolbox.nodePicker.stop({ canceled: true }); 54 55 function doKeyHover(key) { 56 info("Key pressed. Waiting for element to be highlighted/hovered"); 57 const onPickerHovered = toolbox.nodePicker.once("picker-node-hovered"); 58 const onHighlighterShown = waitForHighlighterTypeShown( 59 inspector.highlighters.TYPES.BOXMODEL 60 ); 61 BrowserTestUtils.synthesizeKey(key, {}, gBrowser.selectedBrowser); 62 return Promise.all([onPickerHovered, onHighlighterShown]); 63 } 64 });