1
0
Fork 0
firefox/devtools/server/tests/browser/browser_styles_getRuleText.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

34 lines
908 B
JavaScript

/* 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();
});