Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / insert-node.html
blob34522e5cee400c0b9252b247445d0739dc94c864
1 <html>
2 <head>
3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/elements-test.js"></script>
5 <script>
7 function insertBeforeFirst()
9 var container = document.getElementById("container");
10 var child = document.createElement("div");
11 child.setAttribute("id", "child-before");
12 container.insertBefore(child, container.firstChild);
15 function insertNode()
17 var container = document.getElementById("container");
18 var child2 = document.getElementById("child2");
19 var child = document.createElement("div");
20 child.setAttribute("id", "child-middle");
21 container.insertBefore(child, child2);
24 function appendChild()
26 var container = document.getElementById("container");
27 var child = document.createElement("div");
28 child.setAttribute("id", "child-after");
29 container.appendChild(child);
32 function appendChildWithText()
34 var container = document.getElementById("container");
35 var child = document.createElement("div");
36 child.setAttribute("id", "child-with-text");
37 child.setAttribute("style", "display: none;");
38 child.innerText = "Text";
39 container.appendChild(child);
42 function insertFirstTextNode()
44 var child3 = document.getElementById("child3");
45 child3.innerText = "First text";
48 function test()
50 var containerNode;
52 InspectorTest.runTestSuite([
53 function testDumpInitial(next)
55 function callback(node)
57 containerNode = InspectorTest.expandedNodeWithId("container");
59 InspectorTest.addResult("========= Original ========");
60 InspectorTest.dumpElementsTree(containerNode);
61 next();
63 InspectorTest.expandElementsTree(callback);
66 function testInsertBefore(next)
68 function callback()
70 InspectorTest.addResult("===== Inserted before =====");
71 InspectorTest.dumpElementsTree(containerNode);
72 next();
74 InspectorTest.evaluateInPage("insertBeforeFirst()", callback);
77 function testInsertMiddle(next)
79 function callback()
81 InspectorTest.addResult("===== Inserted middle =====");
82 InspectorTest.dumpElementsTree(containerNode);
83 next();
85 InspectorTest.evaluateInPage("insertNode()", callback);
88 function testAppend(next)
90 function callback()
92 InspectorTest.addResult("======== Appended =========");
93 InspectorTest.dumpElementsTree(containerNode);
94 next();
96 InspectorTest.evaluateInPage("appendChild()", callback);
99 function testAppendWithText(next)
101 function callback()
103 InspectorTest.addResult("======== Appended with text=========");
104 InspectorTest.dumpElementsTree(containerNode);
105 var newNode = InspectorTest.expandedNodeWithId("child-with-text");
106 if (InspectorTest.domModel.nodeForId(newNode.firstChild.id))
107 InspectorTest.addResult("Success: child text is bound");
108 else
109 InspectorTest.addResult("Failed: child text is not bound");
110 next();
112 InspectorTest.evaluateInPage("appendChildWithText()", callback);
115 function testInsertFirstTextNode(next)
117 function callback()
119 InspectorTest.addResult("======== Inserted first text node =========");
120 InspectorTest.expandElementsTree(callback2);
123 function callback2()
125 InspectorTest.dumpElementsTree(containerNode);
126 var newNode = InspectorTest.expandedNodeWithId("child3");
127 if (InspectorTest.domModel.nodeForId(newNode.firstChild.id))
128 InspectorTest.addResult("Success: child text is bound");
129 else
130 InspectorTest.addResult("Failed: child text is not bound");
131 next();
133 InspectorTest.evaluateInPage("insertFirstTextNode()", callback);
138 </script>
139 </head>
141 <body onload="runTest()">
143 Tests that elements panel updates dom tree structure upon node insertion.
144 </p>
146 <div id="container"><div id="child1"></div><div id="child2"></div><div id="child3"></div></div>
148 </body>
149 </html>