Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector-protocol/dom/push-children-on-pseudo-addition.html

Issue 2955943002: DevTools: migrate inspector-protocol/dom tests to a new test runner (Closed)
Patch Set: rebaseline Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource s/inspector-protocol-test.js"></script>
4 <script>
5
6 function addBeforeElement()
7 {
8 document.getElementById("style").textContent = "#for-pseudo:before { content : \"BEFORE\" }";
9 }
10
11 function test()
12 {
13 var nodeInfo = {};
14 var childrenCallback;
15
16 InspectorTest.eventHandler["DOM.setChildNodes"] = setChildNodes;
17 InspectorTest.eventHandler["DOM.pseudoElementAdded"] = pseudoElementAdded;
18 getDocument();
19
20 function getDocument()
21 {
22 step({
23 name: "Get the Document",
24 command: "DOM.getDocument",
25 parameters: {},
26 callback: getImmediateChildren
27 });
28 };
29
30 function getImmediateChildren(result)
31 {
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 });
39 };
40
41 function onChildrenRequested()
42 {
43 step({
44 name: "Add #for-pseudo:before element",
45 command: "Runtime.evaluate",
46 parameters: {expression: "addBeforeElement()"}
47 });
48 }
49
50 function pseudoElementAdded(message)
51 {
52 var nodeData = findNodeById("inner-span");
53 assertEquals(true, !!nodeData, "#inner-span has been received");
54 InspectorTest.completeTest();
55 }
56
57 function setChildNodes(message)
58 {
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();
66 }
67
68 function step(test)
69 {
70 InspectorTest.log("\n=== " + test.name + " ===\n");
71 InspectorTest.sendCommand(test.command, test.parameters, function(messag eObject) {
72 if (messageObject.hasOwnProperty("error"))
73 InspectorTest.log("Backend error: " + messageObject.error.messag e + " (" + messageObject.error.code + ")\n");
74
75 if (test.callback)
76 test.callback(messageObject.result);
77 });
78 }
79
80 function findNodeById(id)
81 {
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};
93 }
94 }
95 return null;
96 }
97
98 function addNodesRecursive(root)
99 {
100 addNode(root);
101 if (!root.children)
102 return;
103 for (var i = 0; i < root.children.length; ++i)
104 addNodesRecursive(root.children[i]);
105 }
106
107 function addNode(node)
108 {
109 nodeInfo[node.nodeId] = node;
110 delete node.nodeId;
111 }
112
113 function assertEquals(expected, actual, message)
114 {
115 if (expected === actual) {
116 InspectorTest.log("PASS: " + message);
117 return;
118 }
119 InspectorTest.log("FAIL: " + message + ": expected: <" + expected + "> b ut found <" + actual + ">");
120 }
121 }
122
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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698