browser_rules_edit-property_05.js (2253B)
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 a disabled property is re-enabled if the property name or value is 7 // modified 8 9 const TEST_URI = ` 10 <style type='text/css'> 11 #testid { 12 background-color: blue; 13 } 14 </style> 15 <div id='testid'>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("#testid", inspector); 22 23 const prop = getTextProperty(view, 1, { "background-color": "blue" }); 24 25 info("Disabling background-color property"); 26 await togglePropStatus(view, prop); 27 28 let newValue = await getRulePropertyValue(0, 0, "background-color"); 29 is(newValue, "", "background-color should have been unset."); 30 31 info( 32 "Entering a new property name, including : to commit and " + 33 "focus the value" 34 ); 35 36 await focusEditableField(view, prop.editor.nameSpan); 37 const onNameDone = view.once("ruleview-changed"); 38 EventUtils.sendString("border-color:", view.styleWindow); 39 await onNameDone; 40 41 info("Escape editing the property value"); 42 const onValueDone = view.once("ruleview-changed"); 43 EventUtils.synthesizeKey("VK_ESCAPE", {}, view.styleWindow); 44 await onValueDone; 45 46 newValue = await getRulePropertyValue(0, 0, "border-color"); 47 is(newValue, "blue", "border-color should have been set."); 48 49 ok(prop.enabled, "border-color property is enabled."); 50 ok( 51 !prop.editor.element.classList.contains("ruleview-overridden"), 52 "border-color is not overridden" 53 ); 54 55 info("Disabling border-color property"); 56 await togglePropStatus(view, prop); 57 58 newValue = await getRulePropertyValue(0, 0, "border-color"); 59 is(newValue, "", "border-color should have been unset."); 60 61 info("Enter a new property value for the border-color property"); 62 await setProperty(view, prop, "red"); 63 64 newValue = await getRulePropertyValue(0, 0, "border-color"); 65 is(newValue, "red", "new border-color should have been set."); 66 67 ok(prop.enabled, "border-color property is enabled."); 68 ok( 69 !prop.editor.element.classList.contains("ruleview-overridden"), 70 "border-color is not overridden" 71 ); 72 });