tor-browser

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

animate-number-calcMode-discrete-keyTimes.html (1920B)


      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("values", "100;200;300");
     29 animate.setAttribute("begin", "0s");
     30 animate.setAttribute("dur", "3s");
     31 animate.setAttribute("keyTimes", "0;0.5;1");
     32 animate.setAttribute("calcMode", "discrete");
     33 animate.setAttribute("fill", "freeze");
     34 rect.appendChild(animate);
     35 rootSVGElement.appendChild(rect);
     36 
     37 // Setup animation test
     38 function sample1() {
     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, 200);
     45    assert_equals(rect.x.baseVal.value, 100);
     46 }
     47 
     48 function sample3() {
     49    assert_equals(rect.x.animVal.value, 300);
     50    assert_equals(rect.x.baseVal.value, 100);
     51 }
     52 
     53 smil_async_test((t) => {
     54    const expectedValues = [
     55        // [animationId, time, sampleCallback]
     56        ["animation", 0.0, sample1],
     57        ["animation", 1.499, sample1],
     58        ["animation", 1.501, sample2],
     59        ["animation", 2.999, sample2],
     60        ["animation", 3.001, sample3]
     61    ];
     62 
     63    runAnimationTest(t, expectedValues);
     64 });
     65 
     66 window.clickX = 150;
     67 
     68 </script>