animateMotion-line.html (1423B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>Test for checking position of the svg element when animateMotion's mpath is a line</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 <line id="line" x2="100" display="none"/> 11 <rect width="50" height="50" x="0" y="0" fill="green"> 12 <animateMotion id="anim" begin="0s" dur="4s" fill="freeze"> 13 <mpath href="#line"/> 14 </animateMotion> 15 </rect> 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(rootSVGElement.getBBox().x, 0, epsilon); 25 } 26 27 function sample2() { 28 assert_approx_equals(rootSVGElement.getBBox().x, 50, epsilon); 29 } 30 31 function sample3() { 32 assert_approx_equals(rootSVGElement.getBBox().x, 100, epsilon); 33 } 34 35 smil_async_test((t) => { 36 var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect"); 37 rect1 = rects[0]; 38 39 const expectedValues = [ 40 // [animationId, time, sampleCallback] 41 ["anim", 0.0, sample1], 42 ["anim", 2.0, sample2], 43 ["anim", 4.0, sample3] 44 ]; 45 46 runAnimationTest(t, expectedValues); 47 }); 48 49 window.animationStartsImmediately = true; 50 51 </script>