browser_rules_edit-selector_07.js (1899B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Tests that the rule view overridden search filter does not appear for an 7 // unmatched rule. 8 9 const TEST_URI = ` 10 <style type="text/css"> 11 div { 12 height: 0px; 13 } 14 #testid { 15 height: 1px; 16 } 17 .testclass { 18 height: 10px; 19 } 20 </style> 21 <div id="testid">Styled Node</div> 22 <span class="testclass">This is a span</span> 23 `; 24 25 add_task(async function () { 26 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 27 const { inspector, view } = await openRuleView(); 28 29 await selectNode("#testid", inspector); 30 await testEditSelector(view, "span"); 31 }); 32 33 async function testEditSelector(view, name) { 34 info("Test editing existing selector fields"); 35 36 let ruleEditor = getRuleViewRuleEditor(view, 1); 37 38 info("Focusing an existing selector name in the rule-view"); 39 const editor = await focusEditableField(view, ruleEditor.selectorText); 40 41 is( 42 inplaceEditor(ruleEditor.selectorText), 43 editor, 44 "The selector editor got focused" 45 ); 46 47 info("Entering a new selector name and committing"); 48 editor.input.value = name; 49 50 info("Entering the commit key"); 51 const onRuleViewChanged = once(view, "ruleview-changed"); 52 EventUtils.synthesizeKey("KEY_Enter"); 53 await onRuleViewChanged; 54 55 // Get the new rule editor that replaced the original 56 ruleEditor = getRuleViewRuleEditor(view, 1); 57 const rule = ruleEditor.rule; 58 const textPropEditor = rule.textProps[0].editor; 59 60 is(view._elementStyle.rules.length, 3, "Should have 3 rules."); 61 ok(getRuleViewRule(view, name), "Rule with " + name + " selector exists."); 62 ok( 63 ruleEditor.element.getAttribute("unmatched"), 64 "Rule with " + name + " does not match the current element." 65 ); 66 ok(!textPropEditor.filterProperty, "Overridden search is hidden."); 67 }