Chromium Code Reviews| 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"/> | 6 <text x="50" y="50" id="log"/> |
| 7 <script id="script"> | 7 <script id="script"> |
| 8 <![CDATA[ | 8 <![CDATA[ |
| 9 | 9 |
| 10 var g = document.getElementById("g"); | 10 var g = document.getElementById("g"); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 anim.setAttribute("to", "0"); | 25 anim.setAttribute("to", "0"); |
| 26 anim.setAttribute("begin", "0s"); | 26 anim.setAttribute("begin", "0s"); |
| 27 anim.setAttribute("dur", "10.0s"); | 27 anim.setAttribute("dur", "10.0s"); |
| 28 anim.setAttribute("repeatCount", 1); | 28 anim.setAttribute("repeatCount", 1); |
| 29 | 29 |
| 30 use.appendChild(anim); | 30 use.appendChild(anim); |
| 31 | 31 |
| 32 return use; | 32 return use; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // With Oilpan tests that rely on garbage collection need to go through | |
| 36 // the event loop in order to get precise garbage collections. Oilpan | |
| 37 // uses conservative stack scanning when not at the event loop and that | |
| 38 // can artificially keep objects alive. Therfore, test that need to check | |
|
wibling-chromium
2014/04/01 13:26:09
Ditto.
Mads Ager (chromium)
2014/04/01 13:45:38
Done.
| |
| 39 // that something is dead need to use this asynchronous collectGarbage | |
| 40 // function. | |
| 41 function collectGarbage(callback) { | |
| 42 GCController.collect(); | |
| 43 setTimeout(function() { | |
| 44 GCController.collect(); | |
| 45 setTimeout(function() { | |
| 46 GCController.collect(); | |
| 47 setTimeout(function() { | |
| 48 GCController.collect(); | |
| 49 setTimeout(callback, 0); | |
| 50 }, 0); | |
| 51 }, 0); | |
| 52 }, 0); | |
| 53 } | |
| 54 | |
| 35 function cleanup() { | 55 function cleanup() { |
| 36 // Collect garbage before recording starting live node count, in case there are live elements from previous tests. | 56 // Collect garbage before recording starting live node count, in case there are live elements from previous tests. |
| 37 GCController.collectAll(); | 57 collectGarbage(function() { |
| 38 var originalLiveElements = internals.numberOfLiveNodes(); | 58 var originalLiveElements = internals.numberOfLiveNodes(); |
| 39 | 59 |
| 40 while (g.hasChildNodes()) | 60 while (g.hasChildNodes()) |
| 41 g.removeChild(g.lastChild); | 61 g.removeChild(g.lastChild); |
| 42 | 62 |
| 43 GCController.collectAll(); | 63 collectGarbage(function() { |
| 64 // This is 400 instead of 200 as it creates shadow tree elements. | |
| 65 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 400; | |
| 66 if (liveDelta == 0) | |
| 67 log("PASS"); | |
| 68 else | |
| 69 log("FAIL: " + liveDelta + " extra live node(s)"); | |
| 44 | 70 |
| 45 // This is 400 instead of 200 as it creates shadow tree elements. | 71 testRunner.notifyDone(); |
| 46 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 400; | 72 }); |
| 47 if (liveDelta == 0) | 73 }); |
| 48 log("PASS"); | |
| 49 else | |
| 50 log("FAIL: " + liveDelta + " extra live node(s)"); | |
| 51 | |
| 52 testRunner.notifyDone(); | |
| 53 } | 74 } |
|
wibling-chromium
2014/04/01 13:26:09
Also can't we waitUntilDone here to not exit until
Mads Ager (chromium)
2014/04/01 13:45:38
Already done in the load function.
| |
| 54 | 75 |
| 55 function startTest() { | 76 function startTest() { |
| 56 // Hold a reference to rect.x.baseVal on the root instance. | 77 // Hold a reference to rect.x.baseVal on the root instance. |
| 57 xBaseVal = document.getElementById("rect").x.baseVal; | 78 xBaseVal = document.getElementById("rect").x.baseVal; |
| 58 | 79 |
| 59 for (var i = 0; i < 100; i++) | 80 for (var i = 0; i < 100; i++) |
| 60 g.appendChild(createAnimatedRectInstance()); | 81 g.appendChild(createAnimatedRectInstance()); |
| 61 | 82 |
| 62 setTimeout(cleanup, 0); | 83 setTimeout(cleanup, 0); |
| 63 } | 84 } |
| 64 | 85 |
| 65 function load() { | 86 function load() { |
| 66 if (window.testRunner && window.GCController && window.internals) { | 87 if (window.testRunner && window.GCController && window.internals) { |
| 67 testRunner.dumpAsText(); | 88 testRunner.dumpAsText(); |
| 68 testRunner.waitUntilDone(); | 89 testRunner.waitUntilDone(); |
| 69 } else { | 90 } else { |
| 70 log("This test only works when run with the testRunner, GCController, an d internals available."); | 91 log("This test only works when run with the testRunner, GCController, an d internals available."); |
| 71 return; | 92 return; |
| 72 } | 93 } |
| 73 | 94 |
| 74 setTimeout(startTest, 0); | 95 setTimeout(startTest, 0); |
| 75 } | 96 } |
| 76 ]]> | 97 ]]> |
| 77 </script> | 98 </script> |
| 78 </svg> | 99 </svg> |
| OLD | NEW |