tor-browser

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

svgenum-animation-8.html (4069B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test ComponentTransferType 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 feRFunc = createSVGElement("feFuncR");
     18 feRFunc.setAttribute("type", "identity");
     19 feRFunc.setAttribute("amplitude", "10");
     20 
     21 var feGFunc = createSVGElement("feFuncG");
     22 feGFunc.setAttribute("type", "identity");
     23 feGFunc.setAttribute("amplitude", "10");
     24 
     25 var feBFunc = createSVGElement("feFuncB");
     26 feBFunc.setAttribute("type", "identity");
     27 feBFunc.setAttribute("amplitude", "110");
     28 
     29 var feAFunc = createSVGElement("feFuncA");
     30 feAFunc.setAttribute("type", "identity");
     31 feAFunc.setAttribute("amplitude", "110");
     32 
     33 var feComponentTransfer = createSVGElement("feComponentTransfer");
     34 feComponentTransfer.appendChild(feRFunc);
     35 feComponentTransfer.appendChild(feGFunc);
     36 feComponentTransfer.appendChild(feBFunc);
     37 feComponentTransfer.appendChild(feAFunc);
     38 
     39 var filter = createSVGElement("filter");
     40 filter.setAttribute("id", "filter");
     41 filter.setAttribute("filterUnits", "objectBoundingBox");
     42 filter.setAttribute("x", "0%");
     43 filter.setAttribute("y", "0%");
     44 filter.setAttribute("width", "100%");
     45 filter.setAttribute("height", "100%");
     46 filter.appendChild(feComponentTransfer);
     47 
     48 var defs = createSVGElement("defs");
     49 defs.appendChild(filter);
     50 rootSVGElement.appendChild(defs);
     51 
     52 var rect = createSVGElement("rect");
     53 rect.setAttribute("id", "rect");
     54 rect.setAttribute("width", "100");
     55 rect.setAttribute("height", "100");
     56 rect.setAttribute("fill", "#408067");
     57 rect.setAttribute("filter", "url(#filter)");
     58 rect.setAttribute("onclick", "executeTest()");
     59 rootSVGElement.appendChild(rect);
     60 
     61 var animate = createSVGElement("animate");
     62 animate.setAttribute("id", "animation");
     63 animate.setAttribute("attributeName", "type");
     64 animate.setAttribute("begin", "0s");
     65 animate.setAttribute("dur", "5s");
     66 animate.setAttribute("values", "identity;table;discrete;linear;gamma");
     67 feRFunc.appendChild(animate);
     68 
     69 // Setup animation test
     70 function sample1() {
     71    assert_equals(feRFunc.type.animVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
     72    assert_equals(feRFunc.type.baseVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
     73 }
     74 
     75 function sample2() {
     76    assert_equals(feRFunc.type.animVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_TABLE);
     77    assert_equals(feRFunc.type.baseVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
     78 }
     79 
     80 function sample3() {
     81    assert_equals(feRFunc.type.animVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE);
     82    assert_equals(feRFunc.type.baseVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
     83 }
     84 
     85 function sample4() {
     86    assert_equals(feRFunc.type.animVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_LINEAR);
     87    assert_equals(feRFunc.type.baseVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
     88 }
     89 
     90 function sample5() {
     91    assert_equals(feRFunc.type.animVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_GAMMA);
     92    assert_equals(feRFunc.type.baseVal, SVGComponentTransferFunctionElement.SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
     93 }
     94 
     95 smil_async_test((t) => {
     96    const expectedValues = [
     97        // [animationId, time, sampleCallback]
     98        ["animation", 0.0,   sample1],
     99        ["animation", 0.999, sample1],
    100        ["animation", 1.001, sample2],
    101        ["animation", 1.999, sample2],
    102        ["animation", 2.001, sample3],
    103        ["animation", 2.999, sample3],
    104        ["animation", 3.001, sample4],
    105        ["animation", 3.999, sample4],
    106        ["animation", 4.001, sample5],
    107        ["animation", 4.999, sample5],
    108        ["animation", 5.001, sample1]
    109    ];
    110 
    111    runAnimationTest(t, expectedValues);
    112 });
    113 
    114 </script>