single-values-animation.html (1384B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>This tests values animation with just a single entry</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 11 <!-- an1: Change width immediately to 100 at 2s --> 12 <rect width="10" height="100" fill="green"> 13 <animate id="an1" attributeType="XML" attributeName="width" fill="freeze" values="100" begin="2s"/> 14 </rect> 15 16 </svg> 17 18 <script> 19 var rootSVGElement = document.querySelector("svg"); 20 var epsilon = 1.0; 21 22 // Setup animation test 23 function sample1() { 24 assert_approx_equals(rect.width.animVal.value, 10, epsilon); 25 assert_equals(rect.width.baseVal.value, 10); 26 } 27 28 function sample2() { 29 assert_approx_equals(rect.width.animVal.value, 100, epsilon); 30 assert_equals(rect.width.baseVal.value, 10); 31 } 32 33 smil_async_test((t) => { 34 rect = rootSVGElement.ownerDocument.getElementsByTagName("rect")[0]; 35 36 const expectedValues = [ 37 // [animationId, time, sampleCallback] 38 ["an1", 0.0, sample1], 39 ["an1", 2.0, sample2], 40 ["an1", 4.0, sample2], 41 ["an1", 60.0, sample2] 42 ]; 43 44 runAnimationTest(t, expectedValues); 45 }); 46 47 window.animationStartsImmediately = true; 48 49 </script>