tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_smilRepeatTiming.xhtml (2637B)


      1 <html xmlns="http://www.w3.org/1999/xhtml">
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=485157
      4 -->
      5 <head>
      6  <title>Test repeat timing</title>
      7  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 </head>
     10 <body>
     11 <a target="_blank"
     12  href="https://bugzilla.mozilla.org/show_bug.cgi?id=485157">Mozilla Bug
     13  485157</a>
     14 <p id="display"></p>
     15 <div id="content" style="display: none">
     16 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100px" height="100px">
     17  <rect width="100" height="100" fill="green">
     18    <set attributeName="width" to="100" dur="20s" repeatCount="5" begin="0s"
     19      id="a" onrepeat="startWaiting(evt)"/>
     20    <set attributeName="fill" attributeType="CSS" to="green"
     21      begin="a.repeat(1)" onbegin="expectedBegin()" dur="20s"/>
     22    <set attributeName="x" to="100"
     23      begin="a.repeat(2)" onbegin="unexpectedBegin(this)" dur="20s"/>
     24    <set attributeName="y" to="100"
     25      begin="a.repeat(0)" onbegin="unexpectedBegin(this)" dur="20s"/>
     26    <set attributeName="width" to="100"
     27      begin="a.repeat(-1)" onbegin="unexpectedBegin(this)" dur="20s"/>
     28    <set attributeName="height" to="100"
     29      begin="a.repeat(a)" onbegin="unexpectedBegin(this)" dur="20s"/>
     30  </rect>
     31 </svg>
     32 </div>
     33 <pre id="test">
     34 <script class="testbody" type="text/javascript">
     35 <![CDATA[
     36 /** Test SMIL repeat timing */
     37 
     38 /* Global Variables */
     39 const gTimeoutDur = 5000; // Time until we give up waiting for events in ms
     40 var gSvg  = document.getElementById('svg');
     41 var gRect = document.getElementById('circle');
     42 var gTimeoutID;
     43 var gGotBegin = false;
     44 
     45 SimpleTest.waitForExplicitFinish();
     46 SimpleTest.requestFlakyTimeout("untriaged");
     47 
     48 function testBegin()
     49 {
     50  gSvg.setCurrentTime(19.999);
     51 }
     52 
     53 function startWaiting(evt)
     54 {
     55  is(evt.detail, 1, "Unexpected repeat event received: test broken");
     56  if (gGotBegin)
     57    return;
     58 
     59  gTimeoutID = setTimeout(timeoutFail, gTimeoutDur);
     60 }
     61 
     62 function timeoutFail()
     63 {
     64  ok(false, "Timed out waiting for begin event");
     65  finish();
     66 }
     67 
     68 function expectedBegin()
     69 {
     70  is(gGotBegin, false,
     71     "Got begin event more than once for non-repeating animation");
     72  gGotBegin = true;
     73  clearTimeout(gTimeoutID);
     74  // Wait a moment before finishing in case there are erroneous events waiting
     75  // to be processed.
     76  setTimeout(finish, 10);
     77 }
     78 
     79 function unexpectedBegin(elem)
     80 {
     81  ok(false, "Got unexpected begin from animation with spec: " +
     82            elem.getAttribute('begin'));
     83 }
     84 
     85 function finish()
     86 {
     87  gSvg.pauseAnimations();
     88  SimpleTest.finish();
     89 }
     90 
     91 window.addEventListener("load", testBegin);
     92 ]]>
     93 </script>
     94 </pre>
     95 </body>
     96 </html>