2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / fast / dom / gc-10.html
blobaa1dd45b2ae6058a9e932058ecb74fbf852add8a
1 <html>
2 <head>
3 <title>GC test 10</title>
4 <script>
5 function print(message, color)
7 var paragraph = document.createElement("div");
8 paragraph.appendChild(document.createTextNode(message));
9 paragraph.style.fontFamily = "monospace";
10 if (color)
11 paragraph.style.color = color;
12 document.getElementById("console").appendChild(paragraph);
15 var before,after;
16 var threshold = 5;
18 function test()
20 if (window.GCController)
22 GCController.collect();
23 before = GCController.getJSObjectCount();
25 window.frames.myframe.location.reload(true);
27 GCController.collect();
28 after = GCController.getJSObjectCount();
30 // Unfortunately we cannot do a strict check here because there is still very minor (3) JS object increase,
31 // likely due to temporary JS objects being created during further execution of this test function.
32 // However, the iframe document leaking everything has an addition of ~25 objects every
33 // refresh, so it still is an accurate test.
34 if (after > (before + threshold))
36 print("FAIL: " + before + " objects before refresh, " + after + " objects after refresh.", "red");
38 else
40 print("PASS: Refresh did not leak JS objects.", "green");
43 else
45 print("WARNING: Test cannot run if GCController does not exist. Thus it only runs from the test interface.", "red");
49 </script>
50 </head>
52 <body style="color: black" onload="test()">
53 <p>This page tests to make sure that the refresh of a page which holds a document reference in its DOM wrapper tree
54 does not leak all of its associated JS objects.</p>
55 <p>If the test passes, you'll see a single 'PASS' message below.</p>
56 <hr>
58 <div id='console'></div>
60 <iframe name="myframe" id="myframe" src="resources/gc-10-frame.html">
61 </body>
62 </html>