Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: third_party/WebKit/LayoutTests/svg/animations/smil-leak-element-instances.svg

Issue 2144473002: rewrite smil-leak tests to rely on layout test leak detector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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[
9 // This test relies on --enable-leak-detection to catch leaks
10 10
11 var g = document.getElementById("g"); 11 var g = document.getElementById("g");
12 12
13 function log(message) {
14 var logDiv = document.getElementById('log');
15 logDiv.appendChild(document.createTextNode(message));
16 }
17
18 function createAnimatedRectInstance() { 13 function createAnimatedRectInstance() {
19 var use = document.createElementNS("http://www.w3.org/2000/svg", "use"); 14 var use = document.createElementNS("http://www.w3.org/2000/svg", "use");
20 use.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#rect"); 15 use.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#rect");
21 16
22 var anim = document.createElementNS("http://www.w3.org/2000/svg", "animate") ; 17 var anim = document.createElementNS("http://www.w3.org/2000/svg", "animate") ;
23 anim.setAttribute("attributeType", "XML"); 18 anim.setAttribute("attributeType", "XML");
24 anim.setAttribute("attributeName", "x"); 19 anim.setAttribute("attributeName", "x");
25 anim.setAttribute("from", "100"); 20 anim.setAttribute("from", "100");
26 anim.setAttribute("to", "0"); 21 anim.setAttribute("to", "0");
27 anim.setAttribute("begin", "0s"); 22 anim.setAttribute("begin", "0s");
28 anim.setAttribute("dur", "10.0s"); 23 anim.setAttribute("dur", "10.0s");
29 anim.setAttribute("repeatCount", 1); 24 anim.setAttribute("repeatCount", 1);
30 25
31 use.appendChild(anim); 26 use.appendChild(anim);
32 27
33 return use; 28 return use;
34 } 29 }
35 30
36 function cleanup() { 31 function load() {
37 // Collect garbage before recording starting live node count, in case there are live elements from previous tests.
38 asyncGC(function() {
39 var originalLiveElements = internals.numberOfLiveNodes();
40
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 if (liveDelta == 0)
48 log("PASS");
49 else
50 log("FAIL: " + liveDelta + " extra live node(s)");
51
52 testRunner.notifyDone();
53 });
54 });
55 }
56
57 function startTest() {
58 // Hold a reference to rect.x.baseVal on the root instance. 32 // Hold a reference to rect.x.baseVal on the root instance.
59 xBaseVal = document.getElementById("rect").x.baseVal; 33 xBaseVal = document.getElementById("rect").x.baseVal;
60 34
61 for (var i = 0; i < 100; i++) 35 for (var i = 0; i < 100; i++)
62 g.appendChild(createAnimatedRectInstance()); 36 g.appendChild(createAnimatedRectInstance());
63
64 // FIXME: we need a better way of waiting for chromium events to happen
65 setTimeout(cleanup, 1);
66 }
67
68 function load() {
69 if (window.testRunner && window.GCController && window.internals) {
70 testRunner.dumpAsText();
71 testRunner.waitUntilDone();
72 } else {
73 log("This test only works when run with the testRunner, GCController, an d internals available.");
74 return;
75 }
76
77 // FIXME: we need a better way of waiting for chromium events to happen
78 setTimeout(startTest, 1);
79 } 37 }
80 ]]> 38 ]]>
81 </script> 39 </script>
82 </svg> 40 </svg>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698