Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / heap-profiler / heap-snapshot-with-detached-dom-tree.html
blobd045de48adc4b7e461f52f29c5eb35df8bf232ef
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script>
5 if (window.testRunner) {
6 testRunner.dumpAsText();
7 testRunner.waitUntilDone();
10 function createDetachedDomTreeAndRunTest()
12 if (window.gc)
13 window.gc();
14 window.retaining_wrapper = document.createElement("div");
15 var t = document.createElement("div");
16 retaining_wrapper.appendChild(t);
17 t.appendChild(document.createElement("div"));
19 if (window.testRunner)
20 runTest();
23 function test()
25 InspectorTest.importScript("../../../../inspector-protocol/heap-profiler/resources/heap-snapshot-common.js");
27 function checkHeapSnapshot(snapshot) {
28 var node;
29 for (var it = snapshot._allNodes(); it.hasNext(); it.next()) {
30 if (it.node.name() === "(Detached DOM trees)") {
31 node = it.node;
32 break;
35 if (node)
36 InspectorTest.log("SUCCESS: found " + node.name());
37 else
38 return InspectorTest.fail("cannot find detached DOM trees root");
40 var detachedDOMTreeRE = /^Detached DOM tree/;
41 var detachedDomTreeFound = false;
42 for (var iter = node.edges(); iter.hasNext(); iter.next()) {
43 var node = iter.edge.node();
44 if (detachedDOMTreeRE.test(node.className())) {
45 if ("Detached DOM tree / 3 entries" === node.name()) {
46 if (detachedDomTreeFound)
47 return InspectorTest.fail("second " + node.name());
48 detachedDomTreeFound = true;
49 InspectorTest.log("SUCCESS: found " + node.name());
50 checkDetachedDOMTreeNodes(node);
51 } else
52 return InspectorTest.fail("unexpected detached DOM tree: " + node.name());
55 InspectorTest.completeTest();
58 function checkDetachedDOMTreeNodes(treeNode)
60 var divCount = 0;
61 for (var iter = treeNode.edges(); iter.hasNext(); iter.next()) {
62 var node = iter.edge.node();
63 if (node.name() === "HTMLDivElement")
64 ++divCount;
65 else
66 return InspectorTest.fail("unexpected DOM wrapper: " + node.name());
68 if (divCount === 3)
69 InspectorTest.log("SUCCESS: found " + divCount + " DIVs in " + treeNode.name());
70 else
71 return InspectorTest.fail("unexpected DIV count: " + divCount);
75 InspectorTest.takeHeapSnapshot(checkHeapSnapshot);
77 </script>
78 </head>
79 <body onload="createDetachedDomTreeAndRunTest()">
80 <p>Test that all nodes from the detached DOM tree will get into one group in the heap snapshot. <a href="https://bugs.webkit.org/show_bug.cgi?id=107819">Bug 107819.</p>
81 </body>
82 </html>