browser_rules_edit-selector-click.js (2252B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Testing selector inplace-editor remains available and focused after clicking 7 // in its input. 8 9 const TEST_URI = ` 10 <style type="text/css"> 11 .testclass { 12 text-align: center; 13 } 14 </style> 15 <div class="testclass">Styled Node</div> 16 `; 17 18 add_task(async function () { 19 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 20 const { inspector, view } = await openRuleView(); 21 await selectNode(".testclass", inspector); 22 await testClickOnSelectorEditorInput(view); 23 }); 24 25 async function testClickOnSelectorEditorInput(view) { 26 info("Test clicking inside the selector editor input"); 27 28 const ruleEditor = getRuleViewRuleEditor(view, 1); 29 30 info("Focusing an existing selector name in the rule-view"); 31 const editor = await focusEditableField(view, ruleEditor.selectorText); 32 const editorInput = editor.input; 33 is( 34 inplaceEditor(ruleEditor.selectorText), 35 editor, 36 "The selector editor got focused" 37 ); 38 39 info("Click inside the editor input"); 40 const onClick = once(editorInput, "click"); 41 EventUtils.synthesizeMouse(editor.input, 2, 1, {}, view.styleWindow); 42 await onClick; 43 is( 44 editor.input, 45 view.styleDocument.activeElement, 46 "The editor input should still be focused" 47 ); 48 ok(!ruleEditor.newPropSpan, "No newProperty editor was created"); 49 50 info("Doubleclick inside the editor input"); 51 const onDoubleClick = once(editorInput, "dblclick"); 52 EventUtils.synthesizeMouse( 53 editor.input, 54 2, 55 1, 56 { clickCount: 2 }, 57 view.styleWindow 58 ); 59 await onDoubleClick; 60 is( 61 editor.input, 62 view.styleDocument.activeElement, 63 "The editor input should still be focused" 64 ); 65 ok(!ruleEditor.newPropSpan, "No newProperty editor was created"); 66 67 info("Click outside the editor input"); 68 const onBlur = once(editorInput, "blur"); 69 const rect = editorInput.getBoundingClientRect(); 70 EventUtils.synthesizeMouse( 71 editorInput, 72 rect.width + 5, 73 rect.height / 2, 74 {}, 75 view.styleWindow 76 ); 77 await onBlur; 78 79 isnot( 80 editorInput, 81 view.styleDocument.activeElement, 82 "The editor input should no longer be focused" 83 ); 84 }