tor-browser

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

svgpointlist-animation-1.html (2246B)


      1 <!doctype html>
      2 <html>
      3 <title>Tests from-to animation of points on polygons.</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/SVGAnimationTestCase-testharness.js"></script>
      7 
      8 <svg>
      9 </svg>
     10 
     11 <script>
     12 var rootSVGElement = document.querySelector("svg");
     13 var epsilon = 1.0;
     14 
     15 // Setup test document
     16 var poly = createSVGElement("polygon");
     17 poly.setAttribute("id", "poly");
     18 poly.setAttribute("fill", "green");
     19 poly.setAttribute("points", "0,0 200,0 200,200 0,200");
     20 poly.setAttribute("onclick", "executeTest()");
     21 
     22 var animate = createSVGElement("animate");
     23 animate.setAttribute("id", "animation");
     24 animate.setAttribute("attributeName", "points");
     25 animate.setAttribute("from", "0,0 200,0 200,200 0,200");
     26 animate.setAttribute("to", "0,0 100,0 100,100 0,100");
     27 animate.setAttribute("begin", "0s");
     28 animate.setAttribute("dur", "4s");
     29 poly.appendChild(animate);
     30 rootSVGElement.appendChild(poly);
     31 
     32 // Setup animation test
     33 function sample1() {
     34    // Check initial/end conditions
     35    assert_approx_equals(poly.animatedPoints.getItem(2).x, 200, epsilon);
     36    assert_approx_equals(poly.animatedPoints.getItem(2).y, 200, epsilon);
     37 
     38    assert_equals(poly.points.getItem(2).x, 200);
     39    assert_equals(poly.points.getItem(2).y, 200);
     40 }
     41 
     42 function sample2() {
     43    // Check half-time conditions
     44    assert_approx_equals(poly.animatedPoints.getItem(2).x, 150, epsilon);
     45    assert_approx_equals(poly.animatedPoints.getItem(2).y, 150, epsilon);
     46 
     47    assert_equals(poly.points.getItem(2).x, 200);
     48    assert_equals(poly.points.getItem(2).y, 200);
     49 }
     50 
     51 function sample3() {
     52    // Check just before-end conditions
     53    assert_approx_equals(poly.animatedPoints.getItem(2).x, 100, epsilon);
     54    assert_approx_equals(poly.animatedPoints.getItem(2).y, 100, epsilon);
     55 
     56    assert_equals(poly.points.getItem(2).x, 200);
     57    assert_equals(poly.points.getItem(2).y, 200);
     58 }
     59 
     60 smil_async_test((t) => {
     61    const expectedValues = [
     62        // [animationId, time, sampleCallback]
     63        ["animation", 0.0,   sample1],
     64        ["animation", 2.0,   sample2],
     65        ["animation", 3.999, sample3],
     66        ["animation", 4.001, sample1]
     67    ];
     68 
     69    runAnimationTest(t, expectedValues);
     70 });
     71 
     72 </script>