tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

animateMotion-circle.html (1638B)


      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 circle</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  <circle id="circle" cx="-100" r="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="#circle"/>
     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    assert_approx_equals(rootSVGElement.getBBox().y, 0, epsilon);
     26 }
     27 
     28 function sample2() {
     29    assert_approx_equals(rootSVGElement.getBBox().x, -200, epsilon);
     30    assert_approx_equals(rootSVGElement.getBBox().y, 0, epsilon);
     31 }
     32 
     33 function sample3() {
     34    assert_approx_equals(rootSVGElement.getBBox().x, 0, epsilon);
     35    assert_approx_equals(rootSVGElement.getBBox().y, 0, epsilon);
     36 }
     37 
     38 smil_async_test((t) => {
     39    var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect");
     40    rect1 = rects[0];
     41 
     42    const expectedValues = [
     43        // [animationId, time, sampleCallback]
     44        ["anim", 0.0,   sample1],
     45        ["anim", 2.0,   sample2],
     46        ["anim", 4.0,   sample3]
     47    ];
     48 
     49    runAnimationTest(t, expectedValues);
     50 });
     51 
     52 window.animationStartsImmediately = true;
     53 
     54 </script>