tor-browser

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

svginteger-animation-2.html (2613B)


      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 1");
     36 feConvolveMatrix.setAttribute("kernelMatrix", "0 0 1");
     37 filter.appendChild(feConvolveMatrix);
     38 
     39 var animate = createSVGElement("animate");
     40 animate.setAttribute("id", "animation");
     41 animate.setAttribute("attributeName", "order");
     42 animate.setAttribute("begin", "0s");
     43 animate.setAttribute("dur", "4s");
     44 animate.setAttribute("from", "3 1");
     45 animate.setAttribute("to", "1 3");
     46 feConvlveMatrix.appendChild(animate);
     47 
     48 // Setup animation test
     49 function sample1() {
     50    assert_approx_equals(feConvolveMatrix.orderX.animVal, 3, epsilon);
     51    assert_approx_equals(feConvolveMatrix.orderY.animVal, 1, epsilon);
     52    assert_equals(feConvolveMatrix.orderX.baseVal, 3);
     53    assert_equals(feConvolveMatrix.orderY.baseVal, 1);
     54 }
     55 
     56 function sample2() {
     57    assert_approx_equals(feConvolveMatrix.orderX.animVal, 2, epsilon);
     58    assert_approx_equals(feConvolveMatrix.orderY.animVal, 2, epsilon);
     59    assert_equals(feConvolveMatrix.orderX.baseVal, 3);
     60    assert_equals(feConvolveMatrix.orderY.baseVal, 1);
     61 }
     62 
     63 function sample3() {
     64    assert_approx_equals(feConvolveMatrix.orderX.animVal, 1, epsilon);
     65    assert_approx_equals(feConvolveMatrix.orderY.animVal, 3, epsilon);
     66    assert_equals(feConvolveMatrix.orderX.baseVal, 3);
     67    assert_equals(feConvolveMatrix.orderY.baseVal, 1);
     68 }
     69 
     70 smil_async_test((t) => {
     71    const expectedValues = [
     72        // [animationId, time, sampleCallback]
     73        ["animation", 0.0,   sample1],
     74        ["animation", 2.0,   sample2],
     75        ["animation", 3.999, sample3],
     76        ["animation", 4.001, sample1]
     77    ];
     78 
     79    runAnimationTest(t, expectedValues);
     80 });
     81 
     82 </script>