Files
firefox/devtools/server/tests/browser/browser_styles_getRuleText.js
T
Razvan Caliman 8c20f33511 Bug 1567164 - Ensure StyleRuleActor.getRuleText() returns text content of minified CSS. r=gl
The patch for Bug 724505 changed the return of `prettifyCSS()` from a string to an object and the reference in the StyleRuleActor.getRuleText() was not updated. This patch fixes this and introduces a test.

Differential Revision: https://phabricator.services.mozilla.com/D38673
2019-07-22 07:58:05 +00:00

36 lines
956 B
JavaScript

/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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();
});