animateMotion-fill-freeze.html (1451B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>Test for animation freeze when repeatDur is not a multiple of dur</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/SVGAnimationTestCase-testharness.js"></script> 8 9 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 10 <rect width="50" height="50" x="0" y="0" fill="green"> 11 <animateMotion id="anim" to="100,0" begin="0s" dur="4s" fill="freeze" /> 12 </rect> 13 </svg> 14 15 <script> 16 var rootSVGElement = document.querySelector("svg"); 17 var epsilon = 1.0; 18 19 // Setup animation test 20 function sample1() { 21 assert_approx_equals(rootSVGElement.getBBox().x, 0, epsilon); 22 } 23 24 function sample2() { 25 assert_approx_equals(rootSVGElement.getBBox().x, 50, epsilon); 26 } 27 28 function sample3() { 29 assert_approx_equals(rootSVGElement.getBBox().x, 100, epsilon); 30 } 31 32 function sample4() { 33 assert_approx_equals(rootSVGElement.getBBox().x, 100, epsilon); 34 } 35 36 smil_async_test((t) => { 37 var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect"); 38 rect1 = rects[0]; 39 40 const expectedValues = [ 41 // [animationId, time, sampleCallback] 42 ["anim", 0.0, sample1], 43 ["anim", 2.0, sample2], 44 ["anim", 4.0, sample3], 45 ["anim", 6.0, sample4] 46 ]; 47 48 runAnimationTest(t, expectedValues); 49 }); 50 51 window.animationStartsImmediately = true; 52 53 </script>