Bug 707733 - Extend timeout for deferred-anim-1.xhtml; r=dholbert a=test-only
authorBrian Birtles <birtles@gmail.com>
Wed, 11 Jul 2012 12:21:50 +0900
changeset 100498 77c4a33c4eaf3e570d3ea368b99bdcc77610057b
parent 100497 949b2aff531c0a3588a6729f1cba9f2031f79346
child 100499 8ebd282004ea25a1ac1edf60fee57c6df17cddd1
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
bugs707733
milestone15.0
Bug 707733 - Extend timeout for deferred-anim-1.xhtml; r=dholbert a=test-only
layout/reftests/svg/smil/container/deferred-anim-1-ref.xhtml
layout/reftests/svg/smil/container/deferred-anim-1.xhtml
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-anim-1-ref.xhtml
+++ b/layout/reftests/svg/smil/container/deferred-anim-1-ref.xhtml
@@ -1,15 +1,12 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <title>Deferred animation</title>
   </head>
 
   <body>
     <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px">
-      <rect x="1" y="1" width="198" height="198"
-        style="fill: none; stroke: black"/>
-      <rect x="90" y="80" width="40" height="40" fill="royalblue"
-        stroke="black" stroke-width="1" id="target"/>
+      <rect width="199" height="199" fill="green"/>
     </svg>
   </body>
 </html>
--- a/layout/reftests/svg/smil/container/deferred-anim-1.xhtml
+++ b/layout/reftests/svg/smil/container/deferred-anim-1.xhtml
@@ -9,40 +9,61 @@
     This test case checks that this case is not neglected.
 
     OPERATION: There is an un-animated document. Then an <animate> element is
     attached to the rectangle by script causing it to move to the right.
     
     EXPECTED RESULTS: The box begins moving from the center.
     -->
     <script>
+        var timeoutID;
+
         function animate()
         {
+          addAnimation();
           var svg = document.getElementsByTagName('svg')[0];
-          addAnimation();
-          setTimeout('document.documentElement.removeAttribute("class")', 150);
+          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.getElementsByTagName('svg')[0];
+          var rect = svg.getElementsByTagName('rect')[0];
+          rect.setAttribute("fill", "red");
+          var anim = svg.getElementsByTagName('animate')[0];
+          anim.parentNode.removeChild(anim);
+          timeoutID = null;
+          finish();
+        }
+
+        function finish() {
+          if (timeoutID) {
+            window.clearTimeout(timeoutID);
+            timeoutID = null;
+          }
+          document.documentElement.removeAttribute('class');
         }
 
         function addAnimation()
         {
           const svgns="http://www.w3.org/2000/svg";
           var anim = document.createElementNS(svgns,'animate');
-          anim.setAttribute('attributeName','x');
-          anim.setAttribute('from','0');
-          anim.setAttribute('to','90');
+          anim.setAttribute('attributeName','fill');
+          anim.setAttribute('to','green');
           anim.setAttribute('begin','0s');
-          anim.setAttribute('dur','0.01s');
+          anim.setAttribute('dur','0.001s');
           anim.setAttribute('fill','freeze');
           var target = document.getElementById('target');
           target.appendChild(anim);
         }
     </script>
   </head>
 
   <body onload="animate()">
     <svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px">
-      <rect x="1" y="1" width="198" height="198"
-        style="fill: none; stroke: black"/>
-      <rect x="-20" y="80" width="40" height="40" fill="royalblue"
-        stroke="black" stroke-width="1" id="target"/>
+      <rect width="199" height="199" fill="red" id="target"/>
     </svg>
   </body>
 </html>
--- a/layout/reftests/svg/smil/container/deferred-tree-1-ref.xhtml
+++ b/layout/reftests/svg/smil/container/deferred-tree-1-ref.xhtml
@@ -1,14 +1,15 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
 <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <title>Deferred tree</title>
   </head>
 
   <body>
-    <p id="tree-container"/>
+    <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" fill="green"/>
       </svg>
+    </p>
   </body>
 </html>
--- a/layout/reftests/svg/smil/container/deferred-tree-1.xhtml
+++ b/layout/reftests/svg/smil/container/deferred-tree-1.xhtml
@@ -33,16 +33,20 @@
           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");
+          // We'll need to clear the animation for this to take effect
+          var anim = svg.getElementsByTagName('animate')[0];
+          anim.parentNode.removeChild(anim);
+          timeoutID = null;
           finish();
         }
 
         function finish() {
           if (timeoutID) {
             window.clearTimeout(timeoutID);
             timeoutID = null;
           }