tor-browser

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

animateMotion-multiple.html (1764B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test for checking position of the svg element when multiple animateMotion are acting on it</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 width="50" height="50" x="0" y="0" fill="green">
     11    <animateMotion id="anim" values="20,0" begin="0s"/>
     12    <animateMotion values="40,0;80,0" begin="2s" dur="4s"/>
     13  </rect>
     14 </svg>
     15 
     16 <script>
     17 var rootSVGElement = document.querySelector("svg");
     18 var epsilon = 1.0;
     19 
     20 // Setup animation test
     21 function sample1() {
     22    assert_approx_equals(rootSVGElement.getBBox().x, 20, epsilon);
     23 }
     24 
     25 function sample2() {
     26    assert_approx_equals(rootSVGElement.getBBox().x, 20, epsilon);
     27 }
     28 
     29 function sample3() {
     30    assert_approx_equals(rootSVGElement.getBBox().x, 40, epsilon);
     31 }
     32 
     33 function sample4() {
     34    assert_approx_equals(rootSVGElement.getBBox().x, 60, epsilon);
     35 }
     36 
     37 function sample5() {
     38    assert_approx_equals(rootSVGElement.getBBox().x, 20, epsilon);
     39 }
     40 
     41 function sample6() {
     42    assert_approx_equals(rootSVGElement.getBBox().x, 20, epsilon);
     43 }
     44 
     45 smil_async_test((t) => {
     46    var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect");
     47    rect1 = rects[0];
     48 
     49    const expectedValues = [
     50        // [animationId, time, sampleCallback]
     51        ["anim", 0.0,   sample1],
     52        ["anim", 1.0,   sample2],
     53        ["anim", 2.0,   sample3],
     54        ["anim", 4.0,   sample4],
     55        ["anim", 6.0,   sample5],
     56        ["anim", 7.0,   sample6]
     57    ];
     58 
     59    runAnimationTest(t, expectedValues);
     60 });
     61 
     62 window.animationStartsImmediately = true;
     63 
     64 </script>