tor-browser

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

svgenum-animation-11.html (3126B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test BlendModeType 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 filter = createSVGElement("filter");
     18 filter.setAttribute("id", "filter");
     19 rootSVGElement.appendChild(filter);
     20 
     21 var feFlood = createSVGElement("feFlood");
     22 feFlood.setAttribute("in", "SourceGraphic");
     23 feFlood.setAttribute("flood-color", "green");
     24 feFlood.setAttribute("flood-opacity", "0.5");
     25 feFlood.setAttribute("result", "img");
     26 filter.appendChild(feFlood);
     27 
     28 var feBlend = createSVGElement("feBlend");
     29 feBlend.setAttribute("in", "SourceGraphic");
     30 feBlend.setAttribute("in2", "img");
     31 feBlend.setAttribute("mode", "lighten");
     32 filter.appendChild(feBlend);
     33 
     34 var rect = createSVGElement("rect");
     35 rect.setAttribute("id", "rect");
     36 rect.setAttribute("onclick", "executeTest()");
     37 rect.setAttribute("filter", "url(#filter)");
     38 rect.setAttribute("width", "100");
     39 rect.setAttribute("height", "100");
     40 rootSVGElement.appendChild(rect);
     41 
     42 var animate1 = createSVGElement("animate");
     43 animate1.setAttribute("id", "animation");
     44 animate1.setAttribute("attributeName", "mode");
     45 animate1.setAttribute("begin", "0s");
     46 animate1.setAttribute("dur", "5s");
     47 animate1.setAttribute("values", "normal;multiply;screen;darken;lighten");
     48 animate1.setAttribute("fill", "freeze");
     49 feBlend.appendChild(animate1);
     50 
     51 // Setup animation test
     52 function sample1() {
     53    assert_equals(feBlend.mode.animVal, SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN);
     54    assert_equals(feBlend.mode.baseVal, SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN);
     55 }
     56 
     57 function sample2() {
     58    assert_equals(feBlend.mode.animVal, SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL);
     59    assert_equals(feBlend.mode.baseVal, SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN);
     60 }
     61 
     62 function sample3() {
     63    assert_equals(feBlend.mode.animVal, SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY);
     64    assert_equals(feBlend.mode.baseVal, SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN);
     65 }
     66 
     67 function sample4() {
     68    assert_equals(feBlend.mode.animVal, SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN);
     69    assert_equals(feBlend.mode.baseVal, SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN);
     70 }
     71 
     72 function sample5() {
     73    assert_equals(feBlend.mode.animVal, SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN);
     74    assert_equals(feBlend.mode.baseVal, SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN);
     75 }
     76 
     77 smil_async_test((t) => {
     78    const expectedValues = [
     79        // [animationId, time, sampleCallback]
     80        ["animation", 0.0,   sample1],
     81        ["animation", 0.001, sample2],
     82        ["animation", 0.999, sample2],
     83        ["animation", 1.001, sample3],
     84        ["animation", 1.999, sample3],
     85        ["animation", 2.001, sample4],
     86        ["animation", 2.999, sample4],
     87        ["animation", 3.001, sample5],
     88        ["animation", 3.999, sample5],
     89        ["animation", 4.001, sample1]
     90    ];
     91 
     92    runAnimationTest(t, expectedValues);
     93 });
     94 
     95 </script>