| <svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="load()"> |
| <defs> |
| <rect id="rect" width="100" height="100" /> |
| </defs> |
| <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 createAnimatedRectInstance() { |
| var use = document.createElementNS("http://www.w3.org/2000/svg", "use"); |
| use.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#rect"); |
| |
| 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); |
| |
| use.appendChild(anim); |
| |
| return use; |
| } |
| |
| function startTest() { |
| // Collect garbage before recording starting live node count, in case there are live elements from previous tests. |
| GCController.collect(); |
| originalLiveElements = window.internals.numberOfLiveNodes(); |
| |
| // Hold a reference to rect.x.baseVal on the root instance. |
| xBaseVal = document.getElementById("rect").x.baseVal; |
| |
| for (var i = 0; i < 100; i++) |
| g.appendChild(createAnimatedRectInstance()); |
| |
| setTimeout(continueTest, 0); |
| } |
| |
| function continueTest() { |
| while (g.hasChildNodes()) |
| g.removeChild(g.lastChild); |
| |
| setTimeout(finishTest, 0); |
| } |
| |
| var attemptsToFinish = 5; |
| |
| function finishTest() { |
| GCController.collect(); |
| |
| var liveDelta = window.internals.numberOfLiveNodes() - originalLiveElements; |
| if (liveDelta == 0) |
| log("PASS"); |
| else if (--attemptsToFinish) { |
| setTimeout(finishTest, 100); |
| return; |
| } else |
| log("FAIL: " + liveDelta + " extra live node(s)"); |
| |
| testRunner.notifyDone(); |
| } |
| |
| 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> |