3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../http/tests/inspector/elements-test.js"></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
);
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";
52 InspectorTest
.runTestSuite([
53 function testDumpInitial(next
)
55 function callback(node
)
57 containerNode
= InspectorTest
.expandedNodeWithId("container");
59 InspectorTest
.addResult("========= Original ========");
60 InspectorTest
.dumpElementsTree(containerNode
);
63 InspectorTest
.expandElementsTree(callback
);
66 function testInsertBefore(next
)
70 InspectorTest
.addResult("===== Inserted before =====");
71 InspectorTest
.dumpElementsTree(containerNode
);
74 InspectorTest
.evaluateInPage("insertBeforeFirst()", callback
);
77 function testInsertMiddle(next
)
81 InspectorTest
.addResult("===== Inserted middle =====");
82 InspectorTest
.dumpElementsTree(containerNode
);
85 InspectorTest
.evaluateInPage("insertNode()", callback
);
88 function testAppend(next
)
92 InspectorTest
.addResult("======== Appended =========");
93 InspectorTest
.dumpElementsTree(containerNode
);
96 InspectorTest
.evaluateInPage("appendChild()", callback
);
99 function testAppendWithText(next
)
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");
109 InspectorTest
.addResult("Failed: child text is not bound");
112 InspectorTest
.evaluateInPage("appendChildWithText()", callback
);
115 function testInsertFirstTextNode(next
)
119 InspectorTest
.addResult("======== Inserted first text node =========");
120 InspectorTest
.expandElementsTree(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");
130 InspectorTest
.addResult("Failed: child text is not bound");
133 InspectorTest
.evaluateInPage("insertFirstTextNode()", callback
);
141 <body onload=
"runTest()">
143 Tests that elements panel updates dom tree structure upon node insertion.
146 <div id=
"container"><div id=
"child1"></div><div id=
"child2"></div><div id=
"child3"></div></div>