browser_rules_mark_overridden_06.js (1915B)
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 marks overridden rules correctly after 7 // editing the selector. 8 9 const TEST_URI = ` 10 <style type='text/css'> 11 div { 12 background-color: blue; 13 background-color: chartreuse; 14 } 15 </style> 16 <div id='testid' class='testclass'>Styled Node</div> 17 `; 18 19 add_task(async function () { 20 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 21 const { inspector, view } = await openRuleView(); 22 await selectNode("#testid", inspector); 23 await testMarkOverridden(inspector, view); 24 }); 25 26 async function testMarkOverridden(inspector, view) { 27 const elementStyle = view._elementStyle; 28 const rule = elementStyle.rules[1]; 29 checkProperties(rule); 30 31 const ruleEditor = getRuleViewRuleEditor(view, 1); 32 info("Focusing an existing selector name in the rule-view"); 33 const editor = await focusEditableField(view, ruleEditor.selectorText); 34 35 info("Entering a new selector name and committing"); 36 editor.input.value = "div[class]"; 37 38 const onRuleViewChanged = once(view, "ruleview-changed"); 39 info("Entering the commit key"); 40 EventUtils.synthesizeKey("KEY_Enter"); 41 await onRuleViewChanged; 42 43 view.searchField.focus(); 44 checkProperties(rule); 45 } 46 47 // A helper to perform a repeated set of checks. 48 function checkProperties(rule) { 49 let prop = rule.textProps[0]; 50 is( 51 prop.name, 52 "background-color", 53 "First property should be background-color" 54 ); 55 is(prop.value, "blue", "First property value should be blue"); 56 ok(prop.overridden, "prop should be overridden."); 57 prop = rule.textProps[1]; 58 is( 59 prop.name, 60 "background-color", 61 "Second property should be background-color" 62 ); 63 is(prop.value, "chartreuse", "First property value should be chartreuse"); 64 ok(!prop.overridden, "prop should not be overridden."); 65 }