browser_inspector_highlighter-eyedropper-show-hide.js (1528B)
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 the basic structure of the eye-dropper highlighter. 7 8 add_task(async function () { 9 const { inspector, highlighterTestFront } = await openInspectorForURL( 10 "data:text/html;charset=utf-8,eye-dropper test" 11 ); 12 13 info("Checking that the eyedropper is hidden by default"); 14 const eyeDropperVisible = await highlighterTestFront.isEyeDropperVisible(); 15 is(eyeDropperVisible, false, "The eyedropper is hidden by default"); 16 17 const toggleButton = inspector.panelDoc.querySelector( 18 "#inspector-eyedropper-toggle" 19 ); 20 21 info("Display the eyedropper by clicking on the inspector toolbar button"); 22 toggleButton.click(); 23 await TestUtils.waitForCondition(() => 24 highlighterTestFront.isEyeDropperVisible() 25 ); 26 ok(true, "Eye dropper is visible after clicking the button in the inspector"); 27 28 const style = await highlighterTestFront.getEyeDropperElementAttribute( 29 "eye-dropper-root", 30 "style" 31 ); 32 is(style, "top:100px;left:100px;", "The eyedropper is correctly positioned"); 33 34 info("Hide the eyedropper by clicking on the inspector toolbar button again"); 35 toggleButton.click(); 36 await TestUtils.waitForCondition(async () => { 37 const visible = await highlighterTestFront.isEyeDropperVisible(); 38 return !visible; 39 }); 40 ok(true, "Eye dropper is not visible anymore"); 41 });