tor-browser

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

animate-calcMode-spline-by.html (2021B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test calcMode spline with by animation. You should see a green 100x100 rect and only PASS messages</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 var rect = createSVGElement("rect");
     18 rect.setAttribute("id", "rect");
     19 rect.setAttribute("x", "100");
     20 rect.setAttribute("width", "100");
     21 rect.setAttribute("height", "100");
     22 rect.setAttribute("fill", "green");
     23 rect.setAttribute("onclick", "executeTest()");
     24 
     25 var animate = createSVGElement("animate");
     26 animate.setAttribute("id", "animation");
     27 animate.setAttribute("attributeName", "x");
     28 animate.setAttribute("by", "-100");
     29 animate.setAttribute("begin", "0s");
     30 animate.setAttribute("dur", "4s");
     31 animate.setAttribute("keyTimes", "0;1");
     32 animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
     33 animate.setAttribute("calcMode", "spline");
     34 rect.appendChild(animate);
     35 rootSVGElement.appendChild(rect);
     36 
     37 // Setup animation test
     38 function sample1() {
     39    // Check initial/end conditions
     40    assert_approx_equals(rect.x.animVal.value, 100, epsilon);
     41    assert_equals(rect.x.baseVal.value, 100);
     42 }
     43 
     44 function sample2() {
     45    // Check half-time conditions
     46    assert_approx_equals(rect.x.animVal.value, 18.8, epsilon);
     47    assert_equals(rect.x.baseVal.value, 100);
     48 }
     49 
     50 function sample3() {
     51    // Check just before-end conditions
     52    assert_approx_equals(rect.x.animVal.value, 0, epsilon);
     53    assert_equals(rect.x.baseVal.value, 100);
     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 window.clickX = 150;
     69 
     70 </script>