browser_styles_getRuleText.js (908B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that StyleRuleActor.getRuleText returns the contents of the CSS rule. 7 8 const CSS_RULE = `#test { 9 background-color: #f06; 10 }`; 11 12 const CONTENT = ` 13 <style type='text/css'> 14 ${CSS_RULE} 15 </style> 16 <div id="test"></div> 17 `; 18 19 const TEST_URI = `data:text/html;charset=utf-8,${encodeURIComponent(CONTENT)}`; 20 21 add_task(async function () { 22 const { inspector, target, walker } = await initInspectorFront(TEST_URI); 23 24 const pageStyle = await inspector.getPageStyle(); 25 const element = await walker.querySelector(walker.rootNode, "#test"); 26 const entries = await pageStyle.getApplied(element, { inherited: false }); 27 28 const rule = entries[1].rule; 29 const text = await rule.getRuleText(); 30 31 is(text, CSS_RULE, "CSS rule text content matches"); 32 33 await target.destroy(); 34 });