2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / dom / gc-2.html
blob5f56929dc6b4ab1ee4347a6415e301908c61c64e
1 <html>
2 <head>
3 <script>
4 function doit()
6 var B = document.getElementById("span-B");
7 B.customProperty = "B";
8 B.parentNode.customProperty = "A";
9 B.firstChild.customProperty = "C";
11 document.getElementById("div").innerHTML = "<span>replacement content</span>";
13 // create lots of objects to force a garbage collection
14 var i = 0;
15 var s;
16 while (i < 5000) {
17 i = i+1.11;
18 s = s + " ";
21 var output= document.getElementById("output");
23 output.innerHTML += B.customProperty + "<BR>";
24 if (B.parentNode) {
25 output.innerHTML += B.parentNode.customProperty + "<BR>";
27 if (B.firstChild) {
28 output.innerHTML += B.firstChild.customProperty + "<BR>";
32 if (window.layoutTestController) {
33 layoutTestController.dumpAsText();
36 </script>
37 </head>
39 <body onload="doit()">
40 <div style="border: 1px solid red">
41 <p>
42 This test verifies that JavaScript wrappers for DOM nodes are
43 protected against garbage collection for node trees that are outside
44 the document, so long as there's a reference to at least one node in
45 the tree.
46 </p>
47 <p>
48 The output should be the following pieces of text on lines by themselves: "replacement content", "B", "A", "C".
49 </p>
50 </div>
51 <div id="div">
52 <span id="span-A"><span id="span-B"><span id="span-C">original span</span></span></span>
53 </div>
54 <div id="output">
55 </div>
56 </body>
57 </html>