browser_inspector_highlighter-eyedropper-keyboard-shortcut.js (1407B)
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 "use strict"; 5 6 // Test that the eye-dropper shortcut works. 7 add_task(async function () { 8 const { toolbox, highlighterTestFront } = await openInspectorForURL( 9 "data:text/html;charset=utf-8,eye-dropper test" 10 ); 11 12 info("Checking that the eyedropper is hidden by default"); 13 const eyeDropperVisible = await highlighterTestFront.isEyeDropperVisible(); 14 is(eyeDropperVisible, false, "The eyedropper is hidden by default"); 15 16 info("Display the eyedropper by pressing the related keyboard shortcut"); 17 18 synthesizeKeyShortcut(INSPECTOR_L10N.getStr("inspector.eyedropper.key")); 19 20 await waitFor( 21 () => highlighterTestFront.isEyeDropperVisible(), 22 "Eye dropper is visible after pressing the shortcut" 23 ); 24 25 const style = await highlighterTestFront.getEyeDropperElementAttribute( 26 "eye-dropper-root", 27 "style" 28 ); 29 is(style, "top:100px;left:100px;", "The eyedropper is correctly positioned"); 30 31 info("Hide the eyedropper by pressing Escape"); 32 EventUtils.synthesizeKey("VK_ESCAPE", {}, toolbox.win); 33 await waitFor(async () => { 34 const visible = await highlighterTestFront.isEyeDropperVisible(); 35 return !visible; 36 }, "Eye dropper is not visible anymore"); 37 ok(true); 38 });