dom/smil/test/test_smilReset.xhtml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <head>
     3   <title>Tests for SMIL Reset Behavior </title>
     4   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     5   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     6 </head>
     7 <body>
     8 <p id="display"></p>
     9 <div id="content" style="display: none">
    10 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px"
    11      onload="this.pauseAnimations()">
    12   <circle cx="20" cy="20" r="15" fill="blue">
    13     <animate attributeName="cx" from="20" to="100" begin="2s" dur="4s"
    14              id="anim1" attributeType="XML"/>
    15   </circle>
    16 </svg>
    17 </div>
    18 <pre id="test">
    19 <script class="testbody" type="text/javascript">
    20 <![CDATA[
    21 /** Tests for SMIL Reset Behavior  **/
    23 SimpleTest.waitForExplicitFinish();
    25 function main() {
    26   var svg = document.getElementById("svg");
    27   ok(svg.animationsPaused(), "should be paused by <svg> load handler");
    28   is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
    30   var anim = document.getElementById("anim1");
    31   is(anim.getStartTime(), 2, "Unexpected initial start time");
    33   svg.setCurrentTime(1);
    34   anim.beginElementAt(2);
    36   // We now have two instance times: 2, 3
    38   // Restart (and reset) animation at t=1
    39   anim.beginElement();
    41   // Instance times should now be 1, 2 (3 should have be reset)
    42   is(anim.getStartTime(), 1,
    43     "Unexpected start time after restart. Perhaps the added instance time "
    44     + "was cleared");
    45   svg.setCurrentTime(4);
    46   // Instance times will now be 2 (1 will have be reset when we restarted)
    47   is(anim.getStartTime(), 2, "Unexpected start time after seek");
    49   // Create a two new instance times at t=4, 5
    50   anim.beginElement();
    51   anim.beginElementAt(1);
    52   is(anim.getStartTime(), 4, "Unexpected start time after beginElement");
    54   // Here is a white box test to make sure we don't discard instance times
    55   // created by DOM calls when setting/unsetting the 'begin' spec
    56   anim.removeAttribute('begin');
    57   is(anim.getStartTime(), 4, "Unexpected start time after clearing begin spec");
    58   svg.setCurrentTime(6);
    59   is(anim.getStartTime(), 5,
    60     "Second DOM instance time cleared when begin spec was removed");
    62   // And likewise, when we set it again
    63   anim.beginElementAt(1); // Instance times now t=5s, 7s
    64   anim.setAttribute('begin', '1s'); // + t=1s
    65   is(anim.getStartTime(), 5, "Unexpected start time after setting begin spec");
    66   svg.setCurrentTime(8);
    67   is(anim.getStartTime(), 7,
    68     "Second DOM instance time cleared when begin spec was added");
    70   // But check we do update state appropriately
    71   anim.setAttribute('begin', '8s');
    72   is(anim.getStartTime(), 8, "Interval not updated with updated begin spec");
    74   SimpleTest.finish();
    75 }
    77 window.addEventListener("load", main, false);
    78 ]]>
    79 </script>
    80 </pre>
    81 </body>
    82 </html>

mercurial