dom/smil/test/test_smilMinTiming.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/smil/test/test_smilMinTiming.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +<!doctype html>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=948245
     1.8 +-->
     1.9 +<head>
    1.10 +  <meta charset="utf-8">
    1.11 +  <title>Test for Bug 948245</title>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=948245">Mozilla Bug 948245</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +<svg id="svg" onload="this.pauseAnimations()">
    1.20 +  <rect fill="red" id="rect" x="0">
    1.21 +    <animate attributeName="x" to="100" id="animation" dur="100s" min="200s"/>
    1.22 +  </rect>
    1.23 +</svg>
    1.24 +</div>
    1.25 +<pre id="test">
    1.26 +<script class="testbody" type="text/javascript">
    1.27 +  // The 'min' attribute introduces a kind of additional state into the SMIL
    1.28 +  // model. If the 'min' attribute extends the active duration, the additional
    1.29 +  // time between the amount of time the animation normally runs for (called the
    1.30 +  // 'repeat duration') and the extended active duration is filled using the
    1.31 +  // fill mode.
    1.32 +  //
    1.33 +  // Below we refer to this period of time between the end of the repeat
    1.34 +  // duration and the end of the active duration as the 'extended period'.
    1.35 +  //
    1.36 +  // This test verifies that as we jump in and out of these states we produce
    1.37 +  // the correct values.
    1.38 +  //
    1.39 +  // The test animation above produces an active interval that is longer than
    1.40 +  // the 'repeating duration' of the animation.
    1.41 +  var rect      = $('rect'),
    1.42 +      animation = $('animation');
    1.43 +
    1.44 +  // Animation doesn't start until onload
    1.45 +  SimpleTest.waitForExplicitFinish();
    1.46 +  window.addEventListener("load", runTests, false);
    1.47 +
    1.48 +  function runTests() {
    1.49 +    ok($('svg').animationsPaused(), "should be paused by <svg> load handler");
    1.50 +
    1.51 +    // In the extended period (t=150s) we should not be animating or filling
    1.52 +    // since the default fill mode is "none".
    1.53 +    animation.ownerSVGElement.setCurrentTime(150);
    1.54 +    ise(rect.x.animVal.value, 0,
    1.55 +        "Shouldn't fill in extended period with fill='none'");
    1.56 +
    1.57 +    // If we set the fill mode we should start filling.
    1.58 +    animation.setAttribute("fill", "freeze");
    1.59 +    ise(rect.x.animVal.value, 100,
    1.60 +        "Should fill in extended period with fill='freeze'");
    1.61 +
    1.62 +    // If we unset the fill attribute we should stop filling.
    1.63 +    animation.removeAttribute("fill");
    1.64 +    ise(rect.x.animVal.value, 0, "Shouldn't fill after unsetting fill");
    1.65 +
    1.66 +    // If we jump back into the repeated interval (at t=50s) we should be
    1.67 +    // animating.
    1.68 +    animation.ownerSVGElement.setCurrentTime(50);
    1.69 +    ise(rect.x.animVal.value, 50, "Should be active in repeating interval");
    1.70 +
    1.71 +    // If we jump to the boundary at the start of the extended period we should
    1.72 +    // not be filling (since we removed the fill attribute above).
    1.73 +    animation.ownerSVGElement.setCurrentTime(100);
    1.74 +    ise(rect.x.animVal.value, 0,
    1.75 +        "Shouldn't fill after seeking to boundary of extended period");
    1.76 +
    1.77 +    // If we apply a fill mode at this boundary point we should do regular fill
    1.78 +    // behavior of using the last value in the interpolation range.
    1.79 +    animation.setAttribute("fill", "freeze");
    1.80 +    ise(rect.x.animVal.value, 100,
    1.81 +        "Should fill at boundary to extended period");
    1.82 +
    1.83 +    // Check that if we seek past the interval we fill with the value at the end
    1.84 +    // of the _repeat_duration_ not the value at the end of the
    1.85 +    // _active_duration_.
    1.86 +    animation.setAttribute("repeatCount", "1.5");
    1.87 +    animation.ownerSVGElement.setCurrentTime(225);
    1.88 +    ise(rect.x.animVal.value, 50,
    1.89 +        "Should fill with the end of the repeat duration value");
    1.90 +
    1.91 +    SimpleTest.finish();
    1.92 +  }
    1.93 +</script>
    1.94 +</pre>
    1.95 +</body>
    1.96 +</html>

mercurial