| OLD | NEW |
| 1 <svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/
1999/xlink" onload="load()"> | 1 <svg id="svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/
1999/xlink" onload="load()"> |
| 2 <defs> | 2 <defs> |
| 3 <rect id="rect" width="100" height="100" /> | 3 <rect id="rect" width="100" height="100" /> |
| 4 </defs> | 4 </defs> |
| 5 <g id="g"/> | 5 <g id="g"/> |
| 6 <text x="50" y="50" id="log"/> | |
| 7 <script xlink:href="../../resources/js-test.js"></script> | 6 <script xlink:href="../../resources/js-test.js"></script> |
| 8 <script id="script"> | 7 <script id="script"> |
| 9 <![CDATA[ | 8 <![CDATA[ |
| 10 | |
| 11 'use strict'; | 9 'use strict'; |
| 12 function log(message) { | 10 // This test relies on --enable-leak-detection to catch leaks |
| 13 var logDiv = document.getElementById('log'); | |
| 14 logDiv.appendChild(document.createTextNode(message)); | |
| 15 } | |
| 16 | 11 |
| 17 function createAnimatedRectInstance() { | 12 function createAnimatedRectInstance() { |
| 18 var use = document.createElementNS("http://www.w3.org/2000/svg", "use"); | 13 var use = document.createElementNS("http://www.w3.org/2000/svg", "use"); |
| 19 use.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#rect"); | 14 use.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#rect"); |
| 20 | 15 |
| 21 var anim = document.createElementNS("http://www.w3.org/2000/svg", "animate")
; | 16 var anim = document.createElementNS("http://www.w3.org/2000/svg", "animate")
; |
| 22 anim.setAttribute("attributeType", "XML"); | 17 anim.setAttribute("attributeType", "XML"); |
| 23 anim.setAttribute("attributeName", "x"); | 18 anim.setAttribute("attributeName", "x"); |
| 24 anim.setAttribute("from", "100"); | 19 anim.setAttribute("from", "100"); |
| 25 anim.setAttribute("to", "0"); | 20 anim.setAttribute("to", "0"); |
| 26 anim.setAttribute("begin", "0s"); | 21 anim.setAttribute("begin", "0s"); |
| 27 anim.setAttribute("dur", "10.0s"); | 22 anim.setAttribute("dur", "10.0s"); |
| 28 anim.setAttribute("repeatCount", 1); | 23 anim.setAttribute("repeatCount", 1); |
| 29 | 24 |
| 30 use.appendChild(anim); | 25 use.appendChild(anim); |
| 31 | 26 |
| 32 return use; | 27 return use; |
| 33 } | 28 } |
| 34 | 29 |
| 35 function cleanup() { | 30 function load() { |
| 36 // Collect garbage before recording starting live node count, in case there
are live elements from previous tests. | |
| 37 asyncGC(function() { | |
| 38 var originalLiveElements = internals.numberOfLiveNodes(); | |
| 39 | |
| 40 var g = document.getElementById("g"); | |
| 41 while (g.hasChildNodes()) | |
| 42 g.removeChild(g.lastChild); | |
| 43 | |
| 44 asyncGC(function() { | |
| 45 // This is 400 instead of 200 as it creates shadow tree elements. | |
| 46 var liveDelta = originalLiveElements - internals.numberOfLiveNodes()
- 400; | |
| 47 | |
| 48 if (liveDelta === 0) | |
| 49 log("PASS"); | |
| 50 else | |
| 51 log("FAIL: " + liveDelta + " extra live node(s)"); | |
| 52 | |
| 53 testRunner.notifyDone(); | |
| 54 }); | |
| 55 }); | |
| 56 } | |
| 57 | |
| 58 function startTest() { | |
| 59 var g = document.getElementById("g"); | 31 var g = document.getElementById("g"); |
| 60 for (var i = 0; i < 100; i++) | 32 for (var i = 0; i < 100; i++) |
| 61 g.appendChild(createAnimatedRectInstance()); | 33 g.appendChild(createAnimatedRectInstance()); |
| 62 | |
| 63 requestAnimationFrame(cleanup); | |
| 64 } | |
| 65 | |
| 66 function load() { | |
| 67 if (window.testRunner && window.GCController && window.internals) { | |
| 68 testRunner.dumpAsText(); | |
| 69 testRunner.waitUntilDone(); | |
| 70 } else { | |
| 71 log("This test only works when run with the testRunner, GCController, an
d internals available."); | |
| 72 return; | |
| 73 } | |
| 74 | |
| 75 requestAnimationFrame(startTest); | |
| 76 } | 34 } |
| 77 ]]> | 35 ]]> |
| 78 </script> | 36 </script> |
| 79 </svg> | 37 </svg> |
| OLD | NEW |