tor-browser

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

svglength-animation-values.html (2193B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test SVGLength animation set with 'values', different units and different count of spaces.</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("onclick", "executeTest()");
     24 
     25 var animate = createSVGElement("animate");
     26 animate.setAttribute("id", "animation");
     27 animate.setAttribute("attributeName", "width");
     28 animate.setAttribute("begin", "0s");
     29 animate.setAttribute("dur", "4s");
     30 animate.setAttribute("values", "100px;  130  ;4cm  ;6in; 200pt");
     31 rect.appendChild(animate);
     32 rootSVGElement.appendChild(rect);
     33 
     34 // Setup animation test
     35 function sample1() {
     36    // Check initial/end conditions
     37    assert_approx_equals(rect.width.animVal.value, 100, epsilon);
     38    assert_equals(rect.width.baseVal.value, 100);
     39 }
     40 
     41 function sample2() {
     42    assert_approx_equals(rect.width.animVal.value, 130, epsilon);
     43    assert_equals(rect.width.baseVal.value, 100);
     44 }
     45 
     46 function sample3() {
     47    assert_approx_equals(rect.width.animVal.value, 151.2, epsilon);
     48    assert_equals(rect.width.baseVal.value, 100);
     49 }
     50 
     51 function sample4() {
     52    assert_approx_equals(rect.width.animVal.value, 576, epsilon);
     53    assert_equals(rect.width.baseVal.value, 100);
     54 }
     55 
     56 function sample5() {
     57    assert_approx_equals(rect.width.animVal.value, 267, epsilon);
     58    assert_equals(rect.width.baseVal.value, 100);
     59 }
     60 
     61 smil_async_test((t) => {
     62    const expectedValues = [
     63        // [animationId, time, sampleCallback]
     64        ["animation", 0.0,   sample1],
     65        ["animation", 1.0,   sample2],
     66        ["animation", 2.0,   sample3],
     67        ["animation", 3.0,   sample4],
     68        ["animation", 3.999, sample5],
     69        ["animation", 4.001, sample1]
     70    ];
     71 
     72    runAnimationTest(t, expectedValues);
     73 });
     74 
     75 </script>