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 collectGarbage(function() { |
37 // FIXME: Unclear why two calls to collect() are required, see crbug.com/307 614 | 57 var originalLiveElements = internals.numberOfLiveNodes(); |
38 GCController.collect(); | |
39 GCController.collect(); | |
40 var originalLiveElements = internals.numberOfLiveNodes(); | |
41 | 58 |
42 while (g.hasChildNodes()) | 59 while (g.hasChildNodes()) |
43 g.removeChild(g.lastChild); | 60 g.removeChild(g.lastChild); |
44 | 61 |
45 GCController.collect(); | 62 collectGarbage(function() { |
63 // FIXME: Why 400 and not 200? | |
64 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 400; | |
65 if (liveDelta == 0) | |
66 log("PASS"); | |
67 else | |
68 log("FAIL: " + liveDelta + " extra live node(s)"); | |
46 | 69 |
47 // FIXME: Why 400 and not 200? | 70 testRunner.notifyDone(); |
48 var liveDelta = originalLiveElements - internals.numberOfLiveNodes() - 400; | 71 }); |
49 if (liveDelta == 0) | 72 }); |
50 log("PASS"); | |
51 else | |
52 log("FAIL: " + liveDelta + " extra live node(s)"); | |
53 | |
54 testRunner.notifyDone(); | |
55 } | 73 } |
wibling-chromium
2014/04/01 13:26:09
Could you do a testRunner.waitUntilDone() here to
Mads Ager (chromium)
2014/04/01 13:45:38
That has already been done. In the onload event we
| |
56 | 74 |
57 function addMoreInstances() { | 75 function addMoreInstances() { |
58 for (var i = 0; i < 50; i++) | 76 for (var i = 0; i < 50; i++) |
59 g.appendChild(createAnimatedRectInstance()); | 77 g.appendChild(createAnimatedRectInstance()); |
60 | 78 |
61 setTimeout(cleanup, 0); | 79 setTimeout(cleanup, 0); |
62 } | 80 } |
63 | 81 |
64 function startTest() { | 82 function startTest() { |
65 for (var i = 0; i < 50; i++) | 83 for (var i = 0; i < 50; i++) |
66 g.appendChild(createAnimatedRectInstance()); | 84 g.appendChild(createAnimatedRectInstance()); |
67 | 85 |
68 setTimeout(addMoreInstances, 100); | 86 setTimeout(addMoreInstances, 100); |
69 } | 87 } |
70 | 88 |
71 function load() { | 89 function load() { |
72 if (window.testRunner && window.GCController && window.internals) { | 90 if (window.testRunner && window.GCController && window.internals) { |
73 testRunner.dumpAsText(); | 91 testRunner.dumpAsText(); |
74 testRunner.waitUntilDone(); | 92 testRunner.waitUntilDone(); |
75 } else { | 93 } else { |
76 log("This test only works when run with the testRunner, GCController, an d internals available."); | 94 log("This test only works when run with the testRunner, GCController, an d internals available."); |
77 return; | 95 return; |
78 } | 96 } |
79 | 97 |
80 setTimeout(startTest, 0); | 98 setTimeout(startTest, 0); |
81 } | 99 } |
82 ]]> | 100 ]]> |
83 </script> | 101 </script> |
84 </svg> | 102 </svg> |
OLD | NEW |