tor-browser

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

svglength-animation-LengthModeOther.html (1905B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test SVGLength animation on LengthModeOther.</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>
     10 </svg>
     11 
     12 <script>
     13 var rootSVGElement = document.querySelector("svg");
     14 var epsilon = 1.0;
     15 
     16 // Setup test document
     17 rootSVGElement.setAttribute("width", "600");
     18 rootSVGElement.setAttribute("height", "400");
     19 
     20 // Setup test document
     21 var circle = createSVGElement("circle");
     22 circle.setAttribute("id", "circle");
     23 circle.setAttribute("cx", "50");
     24 circle.setAttribute("cy", "50");
     25 circle.setAttribute("r", "10");
     26 circle.setAttribute("fill", "green");
     27 circle.setAttribute("onclick", "executeTest()");
     28 
     29 var animate = createSVGElement("animate");
     30 animate.setAttribute("id", "animation");
     31 animate.setAttribute("attributeName", "r");
     32 animate.setAttribute("begin", "0s");
     33 animate.setAttribute("dur", "4s");
     34 animate.setAttribute("from", "10");
     35 animate.setAttribute("to", "50%");
     36 circle.appendChild(animate);
     37 rootSVGElement.appendChild(circle);
     38 
     39 // Setup animation test
     40 function sample1() {
     41    // Check initial/end conditions
     42    assert_approx_equals(circle.r.animVal.value, 10, epsilon);
     43    assert_equals(circle.r.baseVal.value, 10);
     44 }
     45 
     46 function sample2() {
     47    assert_approx_equals(circle.r.animVal.value, 132.5, epsilon);
     48    assert_equals(circle.r.baseVal.value, 10);
     49 }
     50 
     51 function sample3() {
     52    assert_approx_equals(circle.r.animVal.value, 254.9, epsilon);
     53    assert_equals(circle.r.baseVal.value, 10);
     54 }
     55 
     56 smil_async_test((t) => {
     57    const expectedValues = [
     58        // [animationId, time, sampleCallback]
     59        ["animation", 0.0,   sample1],
     60        ["animation", 2.0,   sample2],
     61        ["animation", 3.999, sample3],
     62        ["animation", 4.001, sample1]
     63    ];
     64 
     65    runAnimationTest(t, expectedValues);
     66 });
     67 
     68 </script>