browser_inspector_eyedropper_ruleview.js (1655B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const CSS_URI = URL_ROOT + "style_inspector_eyedropper_ruleview.css"; 7 8 const TEST_URI = ` 9 <link href="${CSS_URI}" rel="stylesheet" type="text/css"/> 10 `; 11 12 // Test that opening the eyedropper before opening devtools doesn't break links 13 // in the ruleview. 14 add_task(async function () { 15 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 16 17 const onPickerCommandHandled = new Promise(r => { 18 const listener = subject => { 19 Services.obs.removeObserver(listener, "color-picker-command-handled"); 20 r(subject.wrappedJSObject); 21 }; 22 Services.obs.addObserver(listener, "color-picker-command-handled"); 23 }); 24 25 info("Trigger the eyedropper command"); 26 const menu = document.getElementById("menu_eyedropper"); 27 menu.doCommand(); 28 29 info("Wait for the color-picker-command-handled observable"); 30 const targetFront = await onPickerCommandHandled; 31 32 info("Wait for the eye dropper to be visible"); 33 const highlighterTestFront = await targetFront.getFront("highlighterTest"); 34 await asyncWaitUntil(() => highlighterTestFront.isEyeDropperVisible()); 35 36 info("Cancel the eye dropper and wait for the target to be destroyed"); 37 EventUtils.synthesizeKey("KEY_Escape"); 38 await waitFor(() => targetFront.isDestroyed()); 39 40 const { inspector, view } = await openRuleView(); 41 42 await selectNode("body", inspector); 43 44 const linkText = getRuleViewLinkTextByIndex(view, 1); 45 is( 46 linkText, 47 "style_inspector_eyedropper_ruleview.css:1", 48 "link text at index 1 has the correct link." 49 ); 50 });