browser_rules_add-rule-and-remove-style-node.js (1376B)
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 bug 1736412 is fixed 7 // We press "add new rule", then we remove the style node 8 // We then try to press "add new rule again" 9 10 const TEST_URI = '<div id="testid">Test Node</div>'; 11 12 add_task(async function () { 13 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 14 const { inspector, view } = await openRuleView(); 15 16 await selectNode("#testid", inspector); 17 await addNewRule(inspector, view); 18 await testNewRule(view, 1); 19 await testRemoveStyleNode(); 20 await addNewRule(inspector, view); 21 await testNewRule(view, 1); 22 }); 23 24 function testNewRule(view) { 25 const ruleEditor = getRuleViewRuleEditor(view, 1); 26 const editor = ruleEditor.selectorText.ownerDocument.activeElement; 27 is(editor.value, "#testid", "Selector editor value is as expected"); 28 info("Escaping from the selector field the change"); 29 EventUtils.synthesizeKey("KEY_Escape"); 30 } 31 32 async function testRemoveStyleNode() { 33 info("Removing the style node from the dom"); 34 const nbStyleSheets = await SpecialPowers.spawn( 35 gBrowser.selectedBrowser, 36 [], 37 () => { 38 content.document.styleSheets[0].ownerNode.remove(); 39 return content.document.styleSheets.length; 40 } 41 ); 42 is(nbStyleSheets, 0, "Style node has been removed"); 43 }