Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / animations / smil-leak-elements.svg
blob3dce2fabf350f20634585372efce56cfadb63ec6
1 <svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" onload="load()">
2 <g id="g"/>
3 <text x="50" y="50" id="log"/>
4 <script xlink:href="../../resources/js-test.js"></script>
5 <script id="script">
6 <![CDATA[
8 var g = document.getElementById("g");
10 function log(message) {
11 var logDiv = document.getElementById('log');
12 logDiv.appendChild(document.createTextNode(message));
15 function createAnimatedRect() {
16 var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
17 rect.setAttribute("width", 10);
18 rect.setAttribute("height", 10);
20 var anim = document.createElementNS("http://www.w3.org/2000/svg", "animate");
21 anim.setAttribute("attributeType", "XML");
22 anim.setAttribute("attributeName", "x");
23 anim.setAttribute("from", "100");
24 anim.setAttribute("to", "0");
25 anim.setAttribute("begin", "0s");
26 anim.setAttribute("dur", "10.0s");
27 anim.setAttribute("repeatCount", 1);
29 rect.appendChild(anim);
31 return rect;
34 function cleanup() {
35 // Collect garbage before recording starting live node count, in case there are live elements from previous tests.
36 asyncGC(function() {
37 var originalLiveElements = internals.numberOfLiveNodes();
39 while (g.hasChildNodes())
40 g.removeChild(g.lastChild);
41 asyncGC(function() {
42 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 200;
43 if (liveDelta == 0)
44 log("PASS");
45 else
46 log("FAIL: " + liveDelta + " extra live node(s)");
47 testRunner.notifyDone();
48 });
49 });
52 function startTest() {
53 for (var i = 0; i < 100; i++)
54 g.appendChild(createAnimatedRect());
56 setTimeout(cleanup, 0);
59 function load() {
60 if (window.testRunner && window.GCController && window.internals) {
61 testRunner.dumpAsText();
62 testRunner.waitUntilDone();
63 } else {
64 log("This test only works when run with the testRunner, GCController, and internals available.");
65 return;
68 setTimeout(startTest, 0);
70 ]]>
71 </script>
72 </svg>