summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_styles_getRuleText.js
blob: e775bcbb284994222281ef34b8587f81c25322cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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();
});