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