blob: cefa0cd9e374ddb51de0b0aefb45d145fac7f1d7 [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 threshold = 5;
function test()
{
if (window.testRunner)
testRunner.dumpAsText();
if (window.GCController)
{
global = window.frames.myframe.location.reload; // Eagerly construct these properties so they don't influence test outcome.
GCController.collect();
var before = GCController.getJSObjectCount();
window.frames.myframe.location.reload(true);
window.frames.myframe.location.reload(true);
window.frames.myframe.location.reload(true);
GCController.collect();
var 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>