svglength-animation-invalid-value-1.html (1733B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>Test SVGLength animation with invalid value: No spaces between number and unit.</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 // Setup test document 17 var rect = createSVGElement("rect"); 18 rect.setAttribute("id", "rect"); 19 rect.setAttribute("x", "0"); 20 rect.setAttribute("width", "100"); 21 rect.setAttribute("height", "100"); 22 rect.setAttribute("fill", "green"); 23 rect.setAttribute("onclick", "executeTest()"); 24 25 var animate = createSVGElement("animate"); 26 animate.setAttribute("id", "animation"); 27 animate.setAttribute("attributeName", "width"); 28 animate.setAttribute("begin", "0s"); 29 animate.setAttribute("dur", "4s"); 30 animate.setAttribute("from", "100 px"); 31 animate.setAttribute("to", "200 px"); 32 rect.appendChild(animate); 33 rootSVGElement.appendChild(rect); 34 35 // Setup animation test 36 function sample1() { 37 assert_approx_equals(rect.width.animVal.value, 100, epsilon); 38 assert_equals(rect.width.baseVal.value, 100); 39 } 40 41 // Per https://www.w3.org/TR/2001/REC-smil-animation-20010904/#ToAttribute 42 // If any values (i.e., the argument-values for from, to, by or values attributes) are not legal, 43 // the animation will have no effect 44 smil_async_test((t) => { 45 const expectedValues = [ 46 // [animationId, time, sampleCallback] 47 ["animation", 0.0, sample1], 48 ["animation", 2.0, sample1], 49 ["animation", 3.999, sample1], 50 ["animation", 4.001, sample1] 51 ]; 52 53 runAnimationTest(t, expectedValues); 54 }); 55 56 </script>