tor-browser

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

svgenum-animation-6.html (3020B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test ColorMatrixType enumeration animations</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 colorMatrix = createSVGElement("feColorMatrix");
     21 colorMatrix.setAttribute("in", "SourceGraphic");
     22 colorMatrix.setAttribute("type", "matrix");
     23 
     24 var filter = createSVGElement("filter");
     25 filter.setAttribute("id", "filter");
     26 filter.setAttribute("filterUnits", "userSpaceOnUse");
     27 filter.setAttribute("x", "0");
     28 filter.setAttribute("y", "0");
     29 filter.setAttribute("width", "700");
     30 filter.setAttribute("height", "200");
     31 filter.appendChild(colorMatrix);
     32 defs.appendChild(filter);
     33 
     34 var rect = createSVGElement("rect");
     35 rect.setAttribute("id", "rect");
     36 rect.setAttribute("width", "100");
     37 rect.setAttribute("height", "100");
     38 rect.setAttribute("fill", "#408067");
     39 rect.setAttribute("filter", "url(#filter)");
     40 rect.setAttribute("onclick", "executeTest()");
     41 rootSVGElement.appendChild(rect);
     42 
     43 var animate = createSVGElement("animate");
     44 animate.setAttribute("id", "animation");
     45 animate.setAttribute("attributeName", "type");
     46 animate.setAttribute("begin", "0s");
     47 animate.setAttribute("dur", "4s");
     48 animate.setAttribute("values", "matrix;saturate;hueRotate;luminanceToAlpha");
     49 colorMatrix.appendChild(animate);
     50 
     51 // Setup animation test
     52 function sample1() {
     53    assert_equals(colorMatrix.type.animVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX);
     54    assert_equals(colorMatrix.type.baseVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX);
     55 }
     56 
     57 function sample2() {
     58    assert_equals(colorMatrix.type.animVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE);
     59    assert_equals(colorMatrix.type.baseVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX);
     60 }
     61 
     62 function sample3() {
     63    assert_equals(colorMatrix.type.animVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_HUEROTATE);
     64    assert_equals(colorMatrix.type.baseVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX);
     65 }
     66 
     67 function sample4() {
     68    assert_equals(colorMatrix.type.animVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA);
     69    assert_equals(colorMatrix.type.baseVal, SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX);
     70 }
     71 
     72 smil_async_test((t) => {
     73    const expectedValues = [
     74        // [animationId, time, sampleCallback]
     75        ["animation", 0.0,   sample1],
     76        ["animation", 0.999, sample1],
     77        ["animation", 1.001, sample2],
     78        ["animation", 1.999, sample2],
     79        ["animation", 2.001, sample3],
     80        ["animation", 2.999, sample3],
     81        ["animation", 3.001, sample4],
     82        ["animation", 3.999, sample4],
     83        ["animation", 4.001, sample1]
     84    ];
     85 
     86    runAnimationTest(t, expectedValues);
     87 });
     88 
     89 </script>