animateMotion-base.html (1349B)
1 <!doctype html> 2 <head> 3 <base href="/"> 4 </head> 5 <html> 6 <title>Test for checking position of the svg element when there is a <base> attribute</title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/SVGAnimationTestCase-testharness.js"></script> 10 11 <svg> 12 <line id="line" x2="100" display="none"/> 13 <rect width="50" height="50" x="0" y="0" fill="green"> 14 <animateMotion id="anim" begin="0s" dur="4s" fill="freeze"> 15 <mpath href="#line"/> 16 </animateMotion> 17 </rect> 18 </svg> 19 20 <script> 21 var rootSVGElement = document.querySelector("svg"); 22 var epsilon = 1.0; 23 24 // Setup animation test 25 function sample1() { 26 assert_approx_equals(rootSVGElement.getBBox().x, 0, epsilon); 27 } 28 29 function sample2() { 30 assert_approx_equals(rootSVGElement.getBBox().x, 50, epsilon); 31 } 32 33 function sample3() { 34 assert_approx_equals(rootSVGElement.getBBox().x, 100, epsilon); 35 } 36 37 smil_async_test((t) => { 38 var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect"); 39 rect1 = rects[0]; 40 41 const expectedValues = [ 42 // [animationId, time, sampleCallback] 43 ["anim", 0.0, sample1], 44 ["anim", 2.0, sample2], 45 ["anim", 4.0, sample3] 46 ]; 47 48 runAnimationTest(t, expectedValues); 49 }); 50 51 window.animationStartsImmediately = true; 52 53 </script>