4 https://bugzilla.mozilla.org/show_bug.cgi?id=
8 <title>Test for Bug
</title>
10 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css">
12 <script type=
"application/javascript" src=
"inspector-helpers.js"></script>
13 <script type=
"application/javascript">
16 const {CssLogic} = require(
"devtools/server/actors/inspector/css-logic");
18 window.onload = function() {
19 SimpleTest.waitForExplicitFinish();
23 addTest(function getComputedStyle() {
24 const node = document.querySelector(
"#computed-style");
25 is(CssLogic.getComputedStyle(node).getPropertyValue(
"width"),
26 "50px",
"Computed style on a normal node works (width)");
27 is(CssLogic.getComputedStyle(node).getPropertyValue(
"height"),
28 "10px",
"Computed style on a normal node works (height)");
30 const firstChild = new _documentWalker(node, window).firstChild();
31 is(CssLogic.getComputedStyle(firstChild).getPropertyValue(
"content"),
32 "\"before\
"",
"Computed style on a ::before node works (content)");
33 const lastChild = new _documentWalker(node, window).lastChild();
34 is(CssLogic.getComputedStyle(lastChild).getPropertyValue(
"content"),
35 "\"after\
"",
"Computed style on a ::after node works (content)");
40 addTest(function getBindingElementAndPseudo() {
41 const node = document.querySelector(
"#computed-style");
42 let {bindingElement, pseudo} = CssLogic.getBindingElementAndPseudo(node);
44 is(bindingElement, node,
45 "Binding element is the node itself for a normal node");
46 ok(!pseudo,
"Pseudo is null for a normal node");
48 const firstChild = new _documentWalker(node, window).firstChild();
49 ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(firstChild));
50 is(bindingElement, node,
51 "Binding element is the parent for a pseudo node");
52 is(pseudo,
"::before",
"Pseudo is correct for a ::before node");
54 const lastChild = new _documentWalker(node, window).lastChild();
55 ({ bindingElement, pseudo } = CssLogic.getBindingElementAndPseudo(lastChild));
56 is(bindingElement, node,
57 "Binding element is the parent for a pseudo node");
58 is(pseudo,
"::after",
"Pseudo is correct for a ::after node");
66 <style type=
"text/css">
67 #computed-style { width: 50px; height: 10px; }
68 #computed-style::before
{ content: "before"; }
69 #computed-style::after
{ content: "after"; }
71 <div id=
"computed-style"></div>