OLD | NEW |
---|---|
1 <svg id="svg" xmlns="http://www.w3.org/2000/svg" onload="load()"> | 1 <svg id="svg" xmlns="http://www.w3.org/2000/svg" onload="load()"> |
2 <g id="g"/> | 2 <g id="g"/> |
3 <text x="50" y="50" id="log"/> | 3 <text x="50" y="50" id="log"/> |
4 <script id="script"> | 4 <script id="script"> |
5 <![CDATA[ | 5 <![CDATA[ |
6 | 6 |
7 var g = document.getElementById("g"); | 7 var g = document.getElementById("g"); |
8 | 8 |
9 function log(message) { | 9 function log(message) { |
10 var logDiv = document.getElementById('log'); | 10 var logDiv = document.getElementById('log'); |
(...skipping 12 matching lines...) Expand all Loading... | |
23 anim.setAttribute("to", "0"); | 23 anim.setAttribute("to", "0"); |
24 anim.setAttribute("begin", "0s"); | 24 anim.setAttribute("begin", "0s"); |
25 anim.setAttribute("dur", "10.0s"); | 25 anim.setAttribute("dur", "10.0s"); |
26 anim.setAttribute("repeatCount", 1); | 26 anim.setAttribute("repeatCount", 1); |
27 | 27 |
28 rect.appendChild(anim); | 28 rect.appendChild(anim); |
29 | 29 |
30 return rect; | 30 return rect; |
31 } | 31 } |
32 | 32 |
33 // With Oilpan tests that rely on garbage collection need to go through | |
34 // the event loop in order to get precise garbage collections. Oilpan | |
35 // uses conservative stack scanning when not at the event loop and that | |
36 // 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.
| |
37 // that something is dead need to use this asynchronous collectGarbage | |
38 // function. | |
39 function collectGarbage(callback) { | |
40 GCController.collect(); | |
41 setTimeout(function() { | |
42 GCController.collect(); | |
43 setTimeout(function() { | |
44 GCController.collect(); | |
45 setTimeout(function() { | |
46 GCController.collect(); | |
47 setTimeout(callback, 0); | |
48 }, 0); | |
49 }, 0); | |
50 }, 0); | |
51 } | |
52 | |
33 function cleanup() { | 53 function cleanup() { |
34 // Collect garbage before recording starting live node count, in case there are live elements from previous tests. | 54 // Collect garbage before recording starting live node count, in case there are live elements from previous tests. |
35 GCController.collectAll(); | 55 collectGarbage(function() { |
36 var originalLiveElements = internals.numberOfLiveNodes(); | 56 var originalLiveElements = internals.numberOfLiveNodes(); |
37 | 57 |
38 while (g.hasChildNodes()) | 58 while (g.hasChildNodes()) |
39 g.removeChild(g.lastChild); | 59 g.removeChild(g.lastChild); |
40 | 60 collectGarbage(function() { |
41 GCController.collectAll(); | 61 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 200; |
42 | 62 if (liveDelta == 0) |
43 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 200; | 63 log("PASS"); |
44 if (liveDelta == 0) | 64 else |
45 log("PASS"); | 65 log("FAIL: " + liveDelta + " extra live node(s)"); |
46 else | 66 testRunner.notifyDone(); |
47 log("FAIL: " + liveDelta + " extra live node(s)"); | 67 }); |
48 | 68 }); |
49 testRunner.notifyDone(); | |
50 } | 69 } |
51 | 70 |
52 function startTest() { | 71 function startTest() { |
53 for (var i = 0; i < 100; i++) | 72 for (var i = 0; i < 100; i++) |
54 g.appendChild(createAnimatedRect()); | 73 g.appendChild(createAnimatedRect()); |
55 | 74 |
56 setTimeout(cleanup, 0); | 75 setTimeout(cleanup, 0); |
57 } | 76 } |
58 | 77 |
59 function load() { | 78 function load() { |
60 if (window.testRunner && window.GCController && window.internals) { | 79 if (window.testRunner && window.GCController && window.internals) { |
61 testRunner.dumpAsText(); | 80 testRunner.dumpAsText(); |
62 testRunner.waitUntilDone(); | 81 testRunner.waitUntilDone(); |
63 } else { | 82 } else { |
64 log("This test only works when run with the testRunner, GCController, an d internals available."); | 83 log("This test only works when run with the testRunner, GCController, an d internals available."); |
65 return; | 84 return; |
66 } | 85 } |
67 | 86 |
68 setTimeout(startTest, 0); | 87 setTimeout(startTest, 0); |
69 } | 88 } |
70 ]]> | 89 ]]> |
71 </script> | 90 </script> |
72 </svg> | 91 </svg> |
OLD | NEW |