svgenum-animation-3.html (1906B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>Test SVGLengthAdjustType enumeration animations</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> 10 </svg> 11 12 <script> 13 var rootSVGElement = document.querySelector("svg"); 14 var epsilon = 1.0; 15 16 // Initiate the test by clicking at (1, 50) - the 'S'. 17 window.clickX = 1; 18 19 // Setup test document 20 var text = createSVGElement("text"); 21 text.setAttribute("id", "text"); 22 text.setAttribute("y", "50"); 23 text.setAttribute("textLength", "200"); 24 text.textContent = "Stretched text"; 25 text.setAttribute("onclick", "executeTest()"); 26 rootSVGElement.appendChild(text); 27 28 var animate = createSVGElement("animate"); 29 animate.setAttribute("id", "animation"); 30 animate.setAttribute("attributeName", "lengthAdjust"); 31 animate.setAttribute("begin", "0s"); 32 animate.setAttribute("dur", "4s"); 33 animate.setAttribute("from", "spacing"); 34 animate.setAttribute("to", "spacingAndGlyphs"); 35 animate.setAttribute("fill", "freeze"); 36 text.appendChild(animate); 37 38 // Setup animation test 39 function sample1() { 40 assert_equals(text.lengthAdjust.animVal, SVGTextContentElement.LENGTHADJUST_SPACING); 41 assert_equals(text.lengthAdjust.baseVal, SVGTextContentElement.LENGTHADJUST_SPACING); 42 } 43 44 function sample2() { 45 assert_equals(text.lengthAdjust.animVal, SVGTextContentElement.LENGTHADJUST_SPACINGANDGLYPHS); 46 assert_equals(text.lengthAdjust.baseVal, SVGTextContentElement.LENGTHADJUST_SPACING); 47 } 48 49 smil_async_test((t) => { 50 const expectedValues = [ 51 // [animationId, time, sampleCallback] 52 ["animation", 0.0, sample1], 53 ["animation", 1.999, sample1], 54 ["animation", 2.001, sample2], 55 ["animation", 3.999, sample2], 56 ["animation", 4.001, sample2] 57 ]; 58 59 runAnimationTest(t, expectedValues); 60 }); 61 62 </script>