dom/smil/test/test_smilMinTiming.html

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

michael@0 1 <!doctype html>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=948245
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug 948245</title>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=948245">Mozilla Bug 948245</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16 <svg id="svg" onload="this.pauseAnimations()">
michael@0 17 <rect fill="red" id="rect" x="0">
michael@0 18 <animate attributeName="x" to="100" id="animation" dur="100s" min="200s"/>
michael@0 19 </rect>
michael@0 20 </svg>
michael@0 21 </div>
michael@0 22 <pre id="test">
michael@0 23 <script class="testbody" type="text/javascript">
michael@0 24 // The 'min' attribute introduces a kind of additional state into the SMIL
michael@0 25 // model. If the 'min' attribute extends the active duration, the additional
michael@0 26 // time between the amount of time the animation normally runs for (called the
michael@0 27 // 'repeat duration') and the extended active duration is filled using the
michael@0 28 // fill mode.
michael@0 29 //
michael@0 30 // Below we refer to this period of time between the end of the repeat
michael@0 31 // duration and the end of the active duration as the 'extended period'.
michael@0 32 //
michael@0 33 // This test verifies that as we jump in and out of these states we produce
michael@0 34 // the correct values.
michael@0 35 //
michael@0 36 // The test animation above produces an active interval that is longer than
michael@0 37 // the 'repeating duration' of the animation.
michael@0 38 var rect = $('rect'),
michael@0 39 animation = $('animation');
michael@0 40
michael@0 41 // Animation doesn't start until onload
michael@0 42 SimpleTest.waitForExplicitFinish();
michael@0 43 window.addEventListener("load", runTests, false);
michael@0 44
michael@0 45 function runTests() {
michael@0 46 ok($('svg').animationsPaused(), "should be paused by <svg> load handler");
michael@0 47
michael@0 48 // In the extended period (t=150s) we should not be animating or filling
michael@0 49 // since the default fill mode is "none".
michael@0 50 animation.ownerSVGElement.setCurrentTime(150);
michael@0 51 ise(rect.x.animVal.value, 0,
michael@0 52 "Shouldn't fill in extended period with fill='none'");
michael@0 53
michael@0 54 // If we set the fill mode we should start filling.
michael@0 55 animation.setAttribute("fill", "freeze");
michael@0 56 ise(rect.x.animVal.value, 100,
michael@0 57 "Should fill in extended period with fill='freeze'");
michael@0 58
michael@0 59 // If we unset the fill attribute we should stop filling.
michael@0 60 animation.removeAttribute("fill");
michael@0 61 ise(rect.x.animVal.value, 0, "Shouldn't fill after unsetting fill");
michael@0 62
michael@0 63 // If we jump back into the repeated interval (at t=50s) we should be
michael@0 64 // animating.
michael@0 65 animation.ownerSVGElement.setCurrentTime(50);
michael@0 66 ise(rect.x.animVal.value, 50, "Should be active in repeating interval");
michael@0 67
michael@0 68 // If we jump to the boundary at the start of the extended period we should
michael@0 69 // not be filling (since we removed the fill attribute above).
michael@0 70 animation.ownerSVGElement.setCurrentTime(100);
michael@0 71 ise(rect.x.animVal.value, 0,
michael@0 72 "Shouldn't fill after seeking to boundary of extended period");
michael@0 73
michael@0 74 // If we apply a fill mode at this boundary point we should do regular fill
michael@0 75 // behavior of using the last value in the interpolation range.
michael@0 76 animation.setAttribute("fill", "freeze");
michael@0 77 ise(rect.x.animVal.value, 100,
michael@0 78 "Should fill at boundary to extended period");
michael@0 79
michael@0 80 // Check that if we seek past the interval we fill with the value at the end
michael@0 81 // of the _repeat_duration_ not the value at the end of the
michael@0 82 // _active_duration_.
michael@0 83 animation.setAttribute("repeatCount", "1.5");
michael@0 84 animation.ownerSVGElement.setCurrentTime(225);
michael@0 85 ise(rect.x.animVal.value, 50,
michael@0 86 "Should fill with the end of the repeat duration value");
michael@0 87
michael@0 88 SimpleTest.finish();
michael@0 89 }
michael@0 90 </script>
michael@0 91 </pre>
michael@0 92 </body>
michael@0 93 </html>

mercurial