tor-browser

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

svgenum-animation-13.html (3672B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test ChannelSelectorType 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 defsElement = createSVGElement("defs");
     18 rootSVGElement.appendChild(defsElement);
     19 
     20 var feImage1 = createSVGElement("feImage");
     21 feImage1.setAttribute("result", "Map");
     22 feImage1.setAttributeNS(xlinkNS, "xlink:href", "../W3C-SVG-1.1/resources/sphere.png");
     23 
     24 var feImage2 = createSVGElement("feImage");
     25 feImage2.setAttribute("result", "Texture");
     26 feImage2.setAttributeNS(xlinkNS, "xlink:href", "../W3C-SVG-1.1/resources/DisplaceChecker.png");
     27 
     28 var displacementMap = createSVGElement("feDisplacementMap");
     29 displacementMap.setAttribute("in", "Texture");
     30 displacementMap.setAttribute("in2", "Map");
     31 displacementMap.setAttribute("scale", "64");
     32 displacementMap.setAttribute("xChannelSelector", "B");
     33 displacementMap.setAttribute("yChannelSelector", "G");
     34 
     35 var filter = createSVGElement("filter");
     36 filter.setAttribute("id", "filter");
     37 filter.setAttribute("filterUnit", "objectBoundingBox");
     38 filter.setAttribute("x", "0");
     39 filter.setAttribute("y", "0");
     40 filter.setAttribute("width", "1");
     41 filter.setAttribute("height", "1");
     42 filter.appendChild(feImage1);
     43 filter.appendChild(feImage2);
     44 filter.appendChild(displacementMap);
     45 defsElement.appendChild(filter);
     46 
     47 var rect = createSVGElement("rect");
     48 rect.setAttribute("id", "rect");
     49 rect.setAttribute("onclick", "executeTest()");
     50 rect.setAttribute("width", "100");
     51 rect.setAttribute("height", "100");
     52 rect.setAttribute("filter", "url(#filter)");
     53 rootSVGElement.appendChild(rect);
     54 
     55 var animate1 = createSVGElement("animate");
     56 animate1.setAttribute("id", "animation");
     57 animate1.setAttribute("attributeName", "xChannelSelector");
     58 animate1.setAttribute("begin", "0s");
     59 animate1.setAttribute("dur", "4s");
     60 animate1.setAttribute("values", "R;G;B;A");
     61 animate1.setAttribute("fill", "freeze");
     62 displacementMap.appendChild(animate1);
     63 
     64 // Setup animation test
     65 function sample1() {
     66    assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
     67    assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
     68 }
     69 
     70 function sample2() {
     71    assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_R);
     72    assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
     73 }
     74 
     75 function sample3() {
     76    assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_G);
     77    assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
     78 }
     79 
     80 function sample4() {
     81    assert_equals(displacementMap.xChannelSelector.animVal, SVGFEDisplacementMapElement.SVG_CHANNEL_A);
     82    assert_equals(displacementMap.xChannelSelector.baseVal, SVGFEDisplacementMapElement.SVG_CHANNEL_B);
     83 }
     84 
     85 smil_async_test((t) => {
     86    const expectedValues = [
     87        // [animationId, time, sampleCallback]
     88        ["animation", 0.0,   sample1],
     89        ["animation", 0.001, sample2],
     90        ["animation", 0.999, sample2],
     91        ["animation", 1.001, sample3],
     92        ["animation", 1.999, sample3],
     93        ["animation", 2.001, sample1],
     94        ["animation", 2.999, sample1],
     95        ["animation", 3.001, sample4],
     96        ["animation", 3.999, sample4],
     97        ["animation", 4.001, sample4]
     98    ];
     99 
    100    runAnimationTest(t, expectedValues);
    101 });
    102 
    103 </script>