tor-browser

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

svgenum-animation-5.html (2458B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test MorphologyOperatorType 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 morphology = createSVGElement("feMorphology");
     21 morphology.setAttribute("in", "SourceAlpha");
     22 morphology.setAttribute("operator", "dilate");
     23 morphology.setAttribute("radius", "4");
     24 
     25 var filter = createSVGElement("filter");
     26 filter.setAttribute("id", "filter");
     27 filter.setAttribute("filterUnits", "userSpaceOnUse");
     28 filter.setAttribute("x", "0");
     29 filter.setAttribute("y", "0");
     30 filter.setAttribute("width", "700");
     31 filter.setAttribute("height", "200");
     32 filter.appendChild(morphology);
     33 defs.appendChild(filter);
     34 
     35 var rect = createSVGElement("rect");
     36 rect.setAttribute("id", "rect");
     37 rect.setAttribute("width", "100");
     38 rect.setAttribute("height", "100");
     39 rect.setAttribute("fill", "#408067");
     40 rect.setAttribute("filter", "url(#filter)");
     41 rect.setAttribute("onclick", "executeTest()");
     42 rootSVGElement.appendChild(rect);
     43 
     44 var animate = createSVGElement("animate");
     45 animate.setAttribute("id", "animation");
     46 animate.setAttribute("attributeName", "operator");
     47 animate.setAttribute("begin", "0s");
     48 animate.setAttribute("dur", "4s");
     49 animate.setAttribute("from", "dilate");
     50 animate.setAttribute("to", "erode");
     51 morphology.appendChild(animate);
     52 
     53 // Setup animation test
     54 function sample1() {
     55    assert_equals(morphology.operator.animVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE);
     56    assert_equals(morphology.operator.baseVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE);
     57 }
     58 
     59 function sample2() {
     60    assert_equals(morphology.operator.animVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_ERODE);
     61    assert_equals(morphology.operator.baseVal, SVGFEMorphologyElement.SVG_MORPHOLOGY_OPERATOR_DILATE);
     62 }
     63 
     64 smil_async_test((t) => {
     65    const expectedValues = [
     66        // [animationId, time, sampleCallback]
     67        ["animation", 0.0,   sample1],
     68        ["animation", 1.999, sample1],
     69        ["animation", 2.001, sample2],
     70        ["animation", 3.999, sample2],
     71        ["animation", 4.001, sample1]
     72    ];
     73 
     74    runAnimationTest(t, expectedValues);
     75 });
     76 
     77 </script>