tor-browser

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

animateMotion-rect.html (1438B)


      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 rect</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  <rect id="rect" width="100" height="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="#rect"/>
     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, 100, epsilon);
     29 }
     30 
     31 function sample3() {
     32    assert_approx_equals(rootSVGElement.getBBox().x, 0, epsilon);
     33 }
     34 
     35 smil_async_test((t) => {
     36    var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect");
     37    rect1 = rects[1];
     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>