blob: aa1dd45b2ae6058a9e932058ecb74fbf852add8a [file] [log] [blame]
<html>
<head>
<title>GC test 10</title>
<script>
function print(message, color)
{
var paragraph = document.createElement("div");
paragraph.appendChild(document.createTextNode(message));
paragraph.style.fontFamily = "monospace";
if (color)
paragraph.style.color = color;
document.getElementById("console").appendChild(paragraph);
}
var before,after;
var threshold = 5;
function test()
{
if (window.GCController)
{
GCController.collect();
before = GCController.getJSObjectCount();
window.frames.myframe.location.reload(true);
GCController.collect();
after = GCController.getJSObjectCount();
// Unfortunately we cannot do a strict check here because there is still very minor (3) JS object increase,
// likely due to temporary JS objects being created during further execution of this test function.
// However, the iframe document leaking everything has an addition of ~25 objects every
// refresh, so it still is an accurate test.
if (after > (before + threshold))
{
print("FAIL: " + before + " objects before refresh, " + after + " objects after refresh.", "red");
}
else
{
print("PASS: Refresh did not leak JS objects.", "green");
}
}
else
{
print("WARNING: Test cannot run if GCController does not exist. Thus it only runs from the test interface.", "red");
}
}
</script>
</head>
<body style="color: black" onload="test()">
<p>This page tests to make sure that the refresh of a page which holds a document reference in its DOM wrapper tree
does not leak all of its associated JS objects.</p>
<p>If the test passes, you'll see a single 'PASS' message below.</p>
<hr>
<div id='console'></div>
<iframe name="myframe" id="myframe" src="resources/gc-10-frame.html">
</body>
</html>