2011-01-26 Martin Robinson <mrobinson@igalia.com>
[WebKit-https.git] / LayoutTests / inspector / elements-panel-xhtml-structure.xhtml
1 <HTML xmlns="http://www.w3.org/1999/xhtml">
2 <Head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script src="elements-tests.js"></script>
5 <script>
6 <![CDATA[
7 function doit()
8 {
9     function preOutput(result)
10     {
11         var output = document.getElementById("outputPre");
12         output.textContent = result.replace(/\u200b/g, "").replace(/\n/g, "").replace(/</g, "\n<");
13     }
14
15     function nodeDumpCallback(dump)
16     {
17         preOutput(dump);
18         notifyDone();
19     }
20
21     function nodeExpandedCallback(result)
22     {
23         if (result) {
24             preOutput(result);
25             notifyDone();
26         }
27         evaluateInWebInspector("frontend_dumpAllElements", nodeDumpCallback);
28     }
29
30     function domLoadedCallback(result)
31     {
32         if (result) {
33             preOutput(result);
34             notifyDone();
35         }
36         evaluateInWebInspector("frontend_expandNodes", nodeExpandedCallback);
37     }
38
39     evaluateInWebInspector("frontend_loadDOM", domLoadedCallback);
40 }
41
42
43 // Frontend functions.
44
45 function frontend_dumpAllElements(testController)
46 {
47     testController.waitUntilDone();
48     // Need test to be async to expand whole the tree first.
49     frontend_expandDOMSubtreeAndRun(testController, null, frontend_reportMimeTypeAndContent);
50 }
51
52 function frontend_reportMimeTypeAndContent(testController)
53 {
54     testController.notifyDone(WebInspector.mainResource.mimeType + " " + WebInspector.panels.elements.treeOutline.element.textContent);
55 }
56
57 function frontend_expandNodes(testController)
58 {
59     try {
60         var innerMapping = WebInspector.domAgent._idToDOMNode;
61         var treeElement = false;
62         var result = "";
63
64         for (var nodeId in innerMapping) {
65             var node = innerMapping[nodeId];
66             result += node.nodeName + " ";
67             if (node.nodeName === "p") {
68                 treeElement = WebInspector.panels.elements.treeOutline.createTreeElementFor(node);
69                 if (treeElement) {
70                     treeElement.reveal();
71                     treeElement.expand();
72                 }
73             }
74         }
75
76         if (!treeElement) {
77             if (treeElement === false)
78                 testController.notifyDone("No 'p' DOM element found");
79             else
80                 testController.notifyDone("'p' tree element could not be created");
81
82             return;
83         }
84
85         testController.notifyDone("");
86     } catch(e) {
87         testController.notifyDone("expandNode: " + e);
88     }
89 }
90
91 function frontend_loadDOM(testController)
92 {
93     testController.waitUntilDone();
94     // Need test to be async to expand whole the tree first.
95     try {
96         frontend_expandDOMSubtreeAndRun(testController, null, testController.notifyDone.bind(testController, ""));
97     } catch(e) {
98         testController.notifyDone("loadDOM: " + e);
99     }
100 }
101
102 ]]>
103 </script>
104 </Head>
105
106 <body onload="onload()">
107 <p>
108 Tests that elements panel shows XML dom tree structure with closing tags for all elements.
109 </p>
110
111 <hr></hr>
112 <p>Paragraph BR test<br/>Next line
113 </p>
114 <![CDATA[ CData Content ]]>
115
116 <img alt="Random Image"></img>
117
118 <pre id="outputPre">
119 </pre>
120
121 </body>
122 </HTML>