browser_rules_edit-selector_10.js (1902B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Regression test for bug 1293616: make sure that editing a selector 7 // keeps the rule in the proper position. 8 9 const TEST_URI = ` 10 <style type="text/css"> 11 #testid span, #testid p { 12 background: aqua; 13 } 14 span { 15 background: fuchsia; 16 } 17 </style> 18 <div id="testid"> 19 <span class="pickme"> 20 Styled Node 21 </span> 22 </div> 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 await selectNode(".pickme", inspector); 29 await testEditSelector(view); 30 }); 31 32 async function testEditSelector(view) { 33 let ruleEditor = getRuleViewRuleEditor(view, 1); 34 const editor = await focusEditableField(view, ruleEditor.selectorText); 35 36 editor.input.value = "#testid span"; 37 const onRuleViewChanged = once(view, "ruleview-changed"); 38 EventUtils.synthesizeKey("KEY_Enter"); 39 await onRuleViewChanged; 40 41 // Get the new rule editor that replaced the original 42 ruleEditor = getRuleViewRuleEditor(view, 1); 43 44 info("Check that the correct rules are visible"); 45 is(view._elementStyle.rules.length, 3, "Should have 3 rules."); 46 is( 47 ruleEditor.element.getAttribute("unmatched"), 48 "false", 49 "Rule editor is matched." 50 ); 51 52 let props = ruleEditor.rule.textProps; 53 is(props.length, 1, "Rule has correct number of properties"); 54 is(props[0].name, "background", "Found background property"); 55 ok(!props[0].overridden, "Background property is not overridden"); 56 57 ruleEditor = getRuleViewRuleEditor(view, 2); 58 props = ruleEditor.rule.textProps; 59 is(props.length, 1, "Rule has correct number of properties"); 60 is(props[0].name, "background", "Found background property"); 61 ok(props[0].overridden, "Background property is overridden"); 62 }