3 <script type=
"text/javascript" src=
"../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
5 if (window
.testRunner
) {
6 testRunner
.dumpAsText();
7 testRunner
.waitUntilDone();
10 function createDetachedDomTreeAndRunTest()
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
)
25 InspectorTest
.importScript("../../../../inspector-protocol/heap-profiler/resources/heap-snapshot-common.js");
27 function checkHeapSnapshot(snapshot
) {
29 for (var it
= snapshot
._allNodes(); it
.hasNext(); it
.next()) {
30 if (it
.node
.name() === "(Detached DOM trees)") {
36 InspectorTest
.log("SUCCESS: found " + node
.name());
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
);
52 return InspectorTest
.fail("unexpected detached DOM tree: " + node
.name());
55 InspectorTest
.completeTest();
58 function checkDetachedDOMTreeNodes(treeNode
)
61 for (var iter
= treeNode
.edges(); iter
.hasNext(); iter
.next()) {
62 var node
= iter
.edge
.node();
63 if (node
.name() === "HTMLDivElement")
66 return InspectorTest
.fail("unexpected DOM wrapper: " + node
.name());
69 InspectorTest
.log("SUCCESS: found " + divCount
+ " DIVs in " + treeNode
.name());
71 return InspectorTest
.fail("unexpected DIV count: " + divCount
);
75 InspectorTest
.takeHeapSnapshot(checkHeapSnapshot
);
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>