Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / dom / push-children-on-pseudo-addition.html
blob194e5008eeacead39fee6c68bbcafae3696fdc54
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
6 function addBeforeElement()
8 document.getElementById("style").textContent = "#for-pseudo:before { content: \"BEFORE\" }";
11 function test()
13 var nodeInfo = {};
14 var childrenCallback;
16 InspectorTest.eventHandler["DOM.setChildNodes"] = setChildNodes;
17 InspectorTest.eventHandler["DOM.pseudoElementAdded"] = pseudoElementAdded;
18 getDocument();
20 function getDocument()
22 step({
23 name: "Get the Document",
24 command: "DOM.getDocument",
25 parameters: {},
26 callback: getImmediateChildren
27 });
30 function getImmediateChildren(result)
32 var bodyId = result.root.children[0].children[1].nodeId;
33 childrenCallback = onChildrenRequested;
34 step({
35 name: "Get immediate children of the body",
36 command: "DOM.requestChildNodes",
37 parameters: {"nodeId": bodyId}
38 });
41 function onChildrenRequested()
43 step({
44 name: "Add #for-pseudo:before element",
45 command: "Runtime.evaluate",
46 parameters: {expression: "addBeforeElement()"}
47 });
50 function pseudoElementAdded(message)
52 var nodeData = findNodeById("inner-span");
53 assertEquals(true, !!nodeData, "#inner-span has been received");
54 InspectorTest.completeTest();
57 function setChildNodes(message)
59 var nodes = message.params.nodes;
60 for (var i = 0; i < nodes.length; ++i)
61 addNode(nodes[i]);
62 var callback = childrenCallback;
63 childrenCallback = null;
64 if (callback)
65 callback();
68 function step(test)
70 InspectorTest.log("\n=== " + test.name + " ===\n");
71 InspectorTest.sendCommand(test.command, test.parameters, function(messageObject) {
72 if (messageObject.hasOwnProperty("error"))
73 InspectorTest.log("Backend error: " + messageObject.error.message + " (" + messageObject.error.code + ")\n");
75 if (test.callback)
76 test.callback(messageObject.result);
77 });
80 function findNodeById(id)
82 for (var nodeId in nodeInfo) {
83 var node = nodeInfo[nodeId];
84 var attrs = node.attributes;
85 if (!attrs)
86 continue;
87 for (var i = 0; i < attrs.length; i += 2) {
88 var name = attrs[i];
89 if (name !== "id")
90 continue;
91 if (attrs[i + 1] === id)
92 return {nodeId: nodeId, node: node};
95 return null;
98 function addNodesRecursive(root)
100 addNode(root);
101 if (!root.children)
102 return;
103 for (var i = 0; i < root.children.length; ++i)
104 addNodesRecursive(root.children[i]);
107 function addNode(node)
109 nodeInfo[node.nodeId] = node;
110 delete node.nodeId;
113 function assertEquals(expected, actual, message)
115 if (expected === actual) {
116 InspectorTest.log("PASS: " + message);
117 return;
119 InspectorTest.log("FAIL: " + message + ": expected: <" + expected + "> but found <" + actual + ">");
123 </script>
124 <style id="style">
125 </style>
126 </head>
127 <body id="body" onload="runTest()">
128 <div id="for-pseudo"><span id="inner-span"></span></div>
129 </body>
130 </html>