tor-browser

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

animate-number-calcMode-discrete.html (1778B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test calcMode discrete with from-to animation on numbers. You should see a green 100x100 rect and only PASS messages</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", "100");
     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", "x");
     28 animate.setAttribute("from", "100");
     29 animate.setAttribute("to", "0");
     30 animate.setAttribute("begin", "0s");
     31 animate.setAttribute("dur", "4s");
     32 animate.setAttribute("calcMode", "discrete");
     33 rect.appendChild(animate);
     34 rootSVGElement.appendChild(rect);
     35 
     36 // Setup animation test
     37 function sample1() {
     38    // Check initial/end conditions
     39    assert_equals(rect.x.animVal.value, 100);
     40    assert_equals(rect.x.baseVal.value, 100);
     41 }
     42 
     43 function sample2() {
     44    assert_equals(rect.x.animVal.value, 0);
     45    assert_equals(rect.x.baseVal.value, 100);
     46 }
     47 
     48 smil_async_test((t) => {
     49    const expectedValues = [
     50        // [animationId, time, sampleCallback]
     51        ["animation", 0.0,   sample1],
     52        ["animation", 1.999, sample1],
     53        ["animation", 2.001, sample2],
     54        ["animation", 3.999, sample2],
     55        ["animation", 4.001, sample1]
     56    ];
     57 
     58    runAnimationTest(t, expectedValues);
     59 });
     60 
     61 window.clickX = 150;
     62 
     63 </script>