browser_rules_edit-selector_11.js (2060B)
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, where editing a selector should 7 // change the relative priority of the rule. 8 9 const TEST_URI = ` 10 <style type="text/css"> 11 #testid { 12 background: aqua; 13 } 14 .pickme { 15 background: seagreen; 16 } 17 span { 18 background: fuchsia; 19 } 20 </style> 21 <div> 22 <span id="testid" class="pickme"> 23 Styled Node 24 </span> 25 </div> 26 `; 27 28 add_task(async function () { 29 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 30 const { inspector, view } = await openRuleView(); 31 await selectNode(".pickme", inspector); 32 await testEditSelector(view); 33 }); 34 35 async function testEditSelector(view) { 36 let ruleEditor = getRuleViewRuleEditor(view, 1); 37 const editor = await focusEditableField(view, ruleEditor.selectorText); 38 39 editor.input.value = ".pickme"; 40 const onRuleViewChanged = once(view, "ruleview-changed"); 41 EventUtils.synthesizeKey("KEY_Enter"); 42 await onRuleViewChanged; 43 44 // Get the new rule editor that replaced the original 45 ruleEditor = getRuleViewRuleEditor(view, 1); 46 47 info("Check that the correct rules are visible"); 48 is(view._elementStyle.rules.length, 4, "Should have 4 rules."); 49 is( 50 ruleEditor.element.getAttribute("unmatched"), 51 "false", 52 "Rule editor is matched." 53 ); 54 55 let props = ruleEditor.rule.textProps; 56 is(props.length, 1, "Rule has correct number of properties"); 57 is(props[0].name, "background", "Found background property"); 58 is(props[0].value, "aqua", "Background property is aqua"); 59 ok(props[0].overridden, "Background property is overridden"); 60 61 ruleEditor = getRuleViewRuleEditor(view, 2); 62 props = ruleEditor.rule.textProps; 63 is(props.length, 1, "Rule has correct number of properties"); 64 is(props[0].name, "background", "Found background property"); 65 is(props[0].value, "seagreen", "Background property is seagreen"); 66 ok(!props[0].overridden, "Background property is not overridden"); 67 }