diff options
Diffstat (limited to 'devtools/server/tests/browser/browser_styles_getRuleText.js')
-rw-r--r-- | devtools/server/tests/browser/browser_styles_getRuleText.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/devtools/server/tests/browser/browser_styles_getRuleText.js b/devtools/server/tests/browser/browser_styles_getRuleText.js new file mode 100644 index 0000000000..6e1b97a14c --- /dev/null +++ b/devtools/server/tests/browser/browser_styles_getRuleText.js @@ -0,0 +1,34 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test that StyleRuleActor.getRuleText returns the contents of the CSS rule. + +const CSS_RULE = `#test { + background-color: #f06; +}`; + +const CONTENT = ` + <style type='text/css'> + ${CSS_RULE} + </style> + <div id="test"></div> +`; + +const TEST_URI = `data:text/html;charset=utf-8,${encodeURIComponent(CONTENT)}`; + +add_task(async function() { + const { inspector, target, walker } = await initInspectorFront(TEST_URI); + + const pageStyle = await inspector.getPageStyle(); + const element = await walker.querySelector(walker.rootNode, "#test"); + const entries = await pageStyle.getApplied(element, { inherited: false }); + + const rule = entries[1].rule; + const text = await rule.getRuleText(); + + is(text, CSS_RULE, "CSS rule text content matches"); + + await target.destroy(); +}); |