Bug 602504 - Make event-being-timeevent-3.svg pass quickly and fail slowly; r=dholbert
authorBrian Birtles <birtles@gmail.com>
Wed, 28 Sep 2011 08:58:54 +0900
changeset 77737 3548d5c7cde58fbe9e60693b73892776dfe6ad67
parent 77736 8664e35a8af8a6945b4cd5b6761d8b87827ccc39
child 77738 30c186f6b48a7365fa59c4b7f91b077d0f4ef91e
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdholbert
bugs602504
milestone10.0a1
Bug 602504 - Make event-being-timeevent-3.svg pass quickly and fail slowly; r=dholbert
layout/reftests/svg/smil/event/event-begin-timeevent-3.svg
--- a/layout/reftests/svg/smil/event/event-begin-timeevent-3.svg
+++ b/layout/reftests/svg/smil/event/event-begin-timeevent-3.svg
@@ -1,16 +1,36 @@
 <svg xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      class="reftest-wait"
-     onload="
-        document.documentElement.pauseAnimations();
-        document.documentElement.setCurrentTime(0.499);
-        document.documentElement.unpauseAnimations();
-        window.setTimeout(finish, 100, 2);">
+     onload="fastForwardToEvent()">
   <script xlink:href="event-util.js" type="text/javascript"/>
+  <script type="text/javascript">
+    const gTimeoutDur = 60000; // Time until we give up waiting for events in ms
+    var timeoutID;
+    function fastForwardToEvent()
+    {
+      document.documentElement.pauseAnimations();
+      document.documentElement.setCurrentTime(4.99);
+      // This test is designed to pass quickly and fail slowly.
+      // 
+      // In the success case, the second animation will start almost
+      // immediately, fire a beginEvent and trigger gotBegin below.
+      //
+      // In the failure case, the following timeout will fire (after
+      // gTimeoutDur), we'll seek to t=1s (to make sure we show the red
+      // square) and then finish.
+      timeoutID = window.setTimeout(finish, gTimeoutDur,
+                                    1 /*seekTimeInSeconds*/);
+      document.documentElement.unpauseAnimations();
+    }
+    function gotBegin()
+    {
+      window.clearTimeout(timeoutID);
+      finish();
+    }
+  </script>
   <rect width="100" height="100" fill="red">
-    <set attributeName="x" to="0" begin="0s" dur="0.5s" repeatCount="2" id="a"/>
-    <set attributeName="fill" attributeType="CSS"
-      to="green"
-      begin="a.repeatEvent" dur="4s"/>
+    <set attributeName="x" to="0" begin="0s" dur="5s" repeatCount="2" id="a"/>
+    <set attributeName="fill" attributeType="CSS" to="green"
+      begin="a.repeatEvent" onbegin="gotBegin()"/>
   </rect>
 </svg>