blob: 3c4358d1fd4f1572d21059441e46ed39cbcb60bc [file] [log] [blame]
<svg id="svg" xmlns="http://www.w3.org/2000/svg" onload="load()">
<g id="g"/>
<text x="50" y="50" id="log"/>
<script id="script">
<![CDATA[
var g = document.getElementById("g");
function log(message) {
var logDiv = document.getElementById('log');
logDiv.appendChild(document.createTextNode(message));
}
function createAnimatedRect() {
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rect.setAttribute("width", 10);
rect.setAttribute("height", 10);
var anim = document.createElementNS("http://www.w3.org/2000/svg", "animate");
anim.setAttribute("attributeType", "XML");
anim.setAttribute("attributeName", "x");
anim.setAttribute("from", "100");
anim.setAttribute("to", "0");
anim.setAttribute("begin", "0s");
anim.setAttribute("dur", "10.0s");
anim.setAttribute("repeatCount", 1);
rect.appendChild(anim);
return rect;
}
function cleanup() {
// Collect garbage before recording starting live node count, in case there are live elements from previous tests.
// FIXME: Unclear why two calls to collect() are required, see crbug.com/307614
GCController.collect();
GCController.collect();
var originalLiveElements = internals.numberOfLiveNodes();
while (g.hasChildNodes())
g.removeChild(g.lastChild);
GCController.collect();
var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 200;
if (liveDelta == 0)
log("PASS");
else
log("FAIL: " + liveDelta + " extra live node(s)");
testRunner.notifyDone();
}
function startTest() {
for (var i = 0; i < 100; i++)
g.appendChild(createAnimatedRect());
setTimeout(cleanup, 0);
}
function load() {
if (window.testRunner && window.GCController && window.internals) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
} else {
log("This test only works when run with the testRunner, GCController, and internals available.");
return;
}
setTimeout(startTest, 0);
}
]]>
</script>
</svg>