tor-browser

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

svginteger-animation-1.html (2300B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test animation of SVGInteger.</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 defs = createSVGElement("defs");
     18 rootSVGElement.appendChild(defs);
     19 
     20 var filter = createSVGElement("filter");
     21 filter.setAttribute("id", "filter");
     22 defs.appendChild(filter);
     23 
     24 var rect = createSVGElement("rect");
     25 rect.setAttribute("id", "rect");
     26 rect.setAttribute("width", "200");
     27 rect.setAttribute("height", "200");
     28 rect.setAttribute("fill", "green");
     29 rect.setAttribute("filter", "url(#filter)");
     30 rect.setAttribute("onclick", "executeTest()");
     31 rootSVGElement.appendChild(rect);
     32 
     33 var feConvolveMatrix = createSVGElement("feConvolveMatrix");
     34 feConvolveMatrix.setAttribute("id", "feConvlveMatrix");
     35 feConvolveMatrix.setAttribute("order", "3");
     36 feConvolveMatrix.setAttribute("kernelMatrix", "0 0 0   0 1 0   0 0 0");
     37 feConvolveMatrix.setAttribute("targetX", "0");
     38 filter.appendChild(feConvolveMatrix);
     39 
     40 var animate = createSVGElement("animate");
     41 animate.setAttribute("id", "animation");
     42 animate.setAttribute("attributeName", "targetX");
     43 animate.setAttribute("begin", "0s");
     44 animate.setAttribute("dur", "4s");
     45 animate.setAttribute("from", "0");
     46 animate.setAttribute("to", "2");
     47 feConvlveMatrix.appendChild(animate);
     48 
     49 // Setup animation test
     50 function sample1() {
     51    assert_approx_equals(feConvolveMatrix.targetX.animVal, 0, epsilon);
     52    assert_equals(feConvolveMatrix.targetX.baseVal, 0);
     53 }
     54 
     55 function sample2() {
     56    assert_approx_equals(feConvolveMatrix.targetX.animVal, 1, epsilon);
     57    assert_equals(feConvolveMatrix.targetX.baseVal, 0);
     58 }
     59 
     60 function sample3() {
     61    assert_approx_equals(feConvolveMatrix.targetX.animVal, 2, epsilon);
     62    assert_equals(feConvolveMatrix.targetX.baseVal, 0);
     63 }
     64 
     65 smil_async_test((t) => {
     66    const expectedValues = [
     67        // [animationId, time, sampleCallback]
     68        ["animation", 0.0,   sample1],
     69        ["animation", 2.0,   sample2],
     70        ["animation", 3.999, sample3],
     71        ["animation", 4.001, sample1]
     72    ];
     73 
     74    runAnimationTest(t, expectedValues);
     75 });
     76 
     77 </script>