Bug 555392 - Extend timeout for deferred-tree-1.xhtml; r=dholbert a=test-only
authorBrian Birtles <birtles@gmail.com>
Mon, 09 Jul 2012 08:47:08 +0900
changeset 100497 949b2aff531c0a3588a6729f1cba9f2031f79346
parent 100496 7b5be4d31c684170b4a7d5596646feb806b85590
child 100498 77c4a33c4eaf3e570d3ea368b99bdcc77610057b
push id1273
push useremorley@mozilla.com
push dateTue, 14 Aug 2012 14:53:37 +0000
treeherdermozilla-beta@a310ea157435 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, test-only
bugs555392
milestone15.0
Bug 555392 - Extend timeout for deferred-tree-1.xhtml; r=dholbert a=test-only
layout/reftests/svg/smil/container/deferred-tree-1-ref.xhtml
layout/reftests/svg/smil/container/deferred-tree-1.xhtml
--- a/layout/reftests/svg/smil/container/deferred-tree-1-ref.xhtml
+++ b/layout/reftests/svg/smil/container/deferred-tree-1-ref.xhtml
@@ -3,15 +3,12 @@
   <head>
     <title>Deferred tree</title>
   </head>
 
   <body>
     <p id="tree-container"/>
       <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px"
         id="created-svg">
-        <rect x="0" y="0" width="199" height="199"
-          style="fill: none; stroke: black"/>
-        <ellipse stroke-width="1" stroke="black" fill="yellow" cx="100"
-          cy="170" rx="40" ry="20"/>
+        <rect x="0" y="0" width="199" height="199" fill="green"/>
       </svg>
   </body>
 </html>
--- a/layout/reftests/svg/smil/container/deferred-tree-1.xhtml
+++ b/layout/reftests/svg/smil/container/deferred-tree-1.xhtml
@@ -10,65 +10,71 @@
     
     OPERATION: There is a plain XHTML document, but later an SVG document is
     added. This document contains a moving circle.
 
     EXPECTED RESULTS: The SVG document fragment appears containing a circle that
     is animated.
     -->
     <script>
+        var timeoutID;
+
         function animate()
         {
           makeTree();
           var svg = document.getElementById('created-svg');
-          // What we really want to test is that the animation starts by itself
-          // so calls to setCurrentTime won't do. Instead we test the
-          // animation is active in two ways:
-          // (1) Check the DOM
-          if (svg.animationsPaused()) {
-            svg.parentNode.removeChild(svg);
+          var anim = svg.getElementsByTagName('animate')[0];
+          // We should pass quickly and fail slowly.
+          // In the pass case, we'll get an end event almost immediately.
+          // In the failure case, wait 30s before giving up.
+          timeoutID = window.setTimeout(giveUp, 30000);
+          anim.addEventListener('end', finish, true);
+        }
+
+        function giveUp() {
+          var svg = document.getElementById('created-svg');
+          var rect = svg.getElementsByTagName('rect')[0];
+          // It's possible we could arrive here after successfully running the
+          // animation but failing to fire the end event.
+          // Technically that's a pass as far as this test is concerned, but it
+          // will mean every test run is taking 30s longer than it should and
+          // we'd like to know about that so we'll make it a failure.
+          rect.setAttribute("fill", "red");
+          finish();
+        }
+
+        function finish() {
+          if (timeoutID) {
+            window.clearTimeout(timeoutID);
+            timeoutID = null;
           }
-          // (2) Define a really really quick animation (0.01s) and then delay
-          // our snapshot accordingly
-          setTimeout('document.documentElement.removeAttribute("class")', 150);
+          document.documentElement.removeAttribute('class');
         }
 
         function makeTree()
         {
           const svgns="http://www.w3.org/2000/svg";
           var svg = document.createElementNS(svgns, 'svg');
           svg.setAttribute('xmlns', svgns);
           svg.setAttribute('width', '200px');
           svg.setAttribute('height', '200px');
           svg.setAttribute('id', 'created-svg');
           var rect = document.createElementNS(svgns, 'rect');
           rect.setAttribute('x', '0');
           rect.setAttribute('y', '0');
           rect.setAttribute('width', '199');
           rect.setAttribute('height', '199');
-          rect.setAttribute('style', 'fill: none; stroke: black');
-          var ellipse = document.createElementNS(svgns, 'ellipse');
-          ellipse.setAttribute('stroke-width', '1');
-          ellipse.setAttribute('stroke', 'black');
-          ellipse.setAttribute('fill', 'yellow');
-          ellipse.setAttribute('cx', '100');
-          ellipse.setAttribute('cy', '20');
-          ellipse.setAttribute('rx', '40');
-          ellipse.setAttribute('ry', '20');
           var anim = document.createElementNS(svgns, 'animate');
-          anim.setAttribute('attributeName', 'cy');
-          anim.setAttribute('attributeType', 'XML');
+          anim.setAttribute('attributeName', 'fill');
           anim.setAttribute('begin', '0s');
-          anim.setAttribute('from', '20');
-          anim.setAttribute('to', '170');
-          anim.setAttribute('dur', '0.01s');
+          anim.setAttribute('to', 'green');
+          anim.setAttribute('dur', '0.001s');
           anim.setAttribute('fill', 'freeze');
-          ellipse.appendChild(anim);
+          rect.appendChild(anim);
           svg.appendChild(rect);
-          svg.appendChild(ellipse);
           var target = document.getElementById('tree-container');
           target.appendChild(svg);
         }
     </script>
   </head>
 
   <body onload="animate()">
     <p id="tree-container"/>