tor-browser

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

svgnumber-animation-2.html (1742B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test for SVGNumber animation with different exponents.</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 rect = createSVGElement("rect");
     18 rect.setAttribute("id", "rect");
     19 rect.setAttribute("x", "0");
     20 rect.setAttribute("width", "100");
     21 rect.setAttribute("height", "100");
     22 rect.setAttribute("fill", "green");
     23 rect.setAttribute("opacity", "0");
     24 rect.setAttribute("onclick", "executeTest()");
     25 
     26 var animate = createSVGElement("animate");
     27 animate.setAttribute("id", "animation");
     28 animate.setAttribute("attributeName", "opacity");
     29 animate.setAttribute("begin", "0s");
     30 animate.setAttribute("dur", "4s");
     31 animate.setAttribute("from", "0e10");
     32 animate.setAttribute("to", ".1e1");
     33 rect.appendChild(animate);
     34 rootSVGElement.appendChild(rect);
     35 
     36 // Setup animation test
     37 function sample1() {
     38    // Check initial/end conditions
     39    assert_approx_equals(parseFloat(getComputedStyle(rect).opacity), 0, epsilon);
     40 }
     41 
     42 function sample2() {
     43    assert_approx_equals(parseFloat(getComputedStyle(rect).opacity), 0.5, epsilon);
     44 }
     45 
     46 function sample3() {
     47    assert_approx_equals(parseFloat(getComputedStyle(rect).opacity), 1, epsilon);
     48 }
     49 
     50 smil_async_test((t) => {
     51    const expectedValues = [
     52        // [animationId, time, sampleCallback]
     53        ["animation", 0.0,   sample1],
     54        ["animation", 2.0,   sample2],
     55        ["animation", 3.999, sample3],
     56        ["animation", 4.001, sample1]
     57    ];
     58 
     59    runAnimationTest(t, expectedValues);
     60 });
     61 
     62 </script>