4 #inspected:before, .some-other-selector {
14 content:
"EmptyBefore";
18 content:
"EmptyAfter";
21 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
22 <script src=
"../../../http/tests/inspector/elements-test.js"></script>
25 function removeLastRule()
27 document
.styleSheets
[0].deleteRule(document
.styleSheets
[0].cssRules
.length
- 1);
30 function addAfterRule()
32 document
.styleSheets
[0].addRule("#inspected:after", "content: \"AFTER\"");
35 function addBeforeRule()
37 document
.styleSheets
[0].addRule("#inspected:before", "content: \"BEFORE\"");
40 function modifyTextContent()
42 document
.getElementById("inspected").textContent
= "bar";
45 function clearTextContent()
47 document
.getElementById("inspected").textContent
= "";
52 document
.getElementById("inspected").remove();
60 InspectorTest
.runTestSuite([
61 function dumpOriginalTree(next
)
63 InspectorTest
.expandElementsTree(callback
);
66 containerNode
= InspectorTest
.expandedNodeWithId("container");
67 inspectedNode
= InspectorTest
.expandedNodeWithId("inspected");
68 InspectorTest
.addResult("Original elements tree:");
69 InspectorTest
.dumpElementsTree(containerNode
);
74 function dumpNormalNodeStyles(next
)
76 selectNodeAndDumpStyles("inspected", "", next
);
79 function dumpBeforeStyles(next
)
81 selectNodeAndDumpStyles("inspected", "before", next
);
84 function dumpAfterStyles(next
)
86 selectNodeAndDumpStyles("inspected", "after", next
);
89 function removeAfter(next
)
91 executeAndDumpTree("removeLastRule()", WebInspector
.DOMModel
.Events
.NodeRemoved
, next
);
94 function removeBefore(next
)
96 executeAndDumpTree("removeLastRule()", WebInspector
.DOMModel
.Events
.NodeRemoved
, next
);
99 function addAfter(next
)
101 executeAndDumpTree("addAfterRule()", WebInspector
.DOMModel
.Events
.NodeInserted
, expandAndDumpTree
.bind(this, next
));
104 function addBefore(next
)
106 executeAndDumpTree("addBeforeRule()", WebInspector
.DOMModel
.Events
.NodeInserted
, next
);
109 function modifyTextContent(next
)
111 executeAndDumpTree("modifyTextContent()", WebInspector
.DOMModel
.Events
.NodeInserted
, next
);
114 function clearTextContent(next
)
116 executeAndDumpTree("clearTextContent()", WebInspector
.DOMModel
.Events
.NodeRemoved
, next
);
119 function removeNodeAndCheckPseudoElementsUnbound(next
)
121 var inspectedBefore
= inspectedNode
.beforePseudoElement();
122 var inspectedAfter
= inspectedNode
.afterPseudoElement();
124 executeAndDumpTree("removeNode()", WebInspector
.DOMModel
.Events
.NodeRemoved
, callback
);
127 InspectorTest
.addResult("inspected:before DOMNode in DOMAgent: " + !!(InspectorTest
.domModel
.nodeForId(inspectedBefore
.id
)));
128 InspectorTest
.addResult("inspected:after DOMNode in DOMAgent: " + !!(InspectorTest
.domModel
.nodeForId(inspectedAfter
.id
)));
134 function executeAndDumpTree(pageFunction
, eventName
, next
)
136 InspectorTest
.domModel
.addEventListener(eventName
, domCallback
, this);
137 InspectorTest
.evaluateInPage(pageFunction
);
139 function domCallback()
141 InspectorTest
.domModel
.removeEventListener(eventName
, domCallback
, this);
142 InspectorTest
.firstElementsTreeOutline().addEventListener(WebInspector
.ElementsTreeOutline
.Events
.ElementsTreeUpdated
, treeCallback
, this);
145 function treeCallback()
147 InspectorTest
.firstElementsTreeOutline().removeEventListener(WebInspector
.ElementsTreeOutline
.Events
.ElementsTreeUpdated
, treeCallback
, this);
148 InspectorTest
.dumpElementsTree(containerNode
);
153 function expandAndDumpTree(next
)
155 InspectorTest
.addResult("== Expanding: ==");
156 InspectorTest
.expandElementsTree(callback
);
159 InspectorTest
.dumpElementsTree(containerNode
);
164 function selectNodeAndDumpStyles(id
, pseudoTypeName
, callback
)
167 InspectorTest
.selectPseudoElementAndWaitForStyles("inspected", pseudoTypeName
, stylesCallback
);
169 InspectorTest
.selectNodeAndWaitForStyles("inspected", stylesCallback
);
171 function stylesCallback()
173 InspectorTest
.dumpSelectedElementStyles(true, false, false, true);
182 <body onload=
"runTest()">
184 Tests that pseudo elements and their styles are handled properly.
188 <div id=
"inspected">Text
</div>
189 <div id=
"empty"></div>