tor-browser

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

animate-dynamic-update-attributeName.html (1902B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Test behavior on dynamic-update of attributeName</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("width", "200");
     20 rect.setAttribute("height", "200");
     21 rect.setAttribute("fill", "red");
     22 rect.setAttribute("color", "red");
     23 rect.setAttribute("onclick", "executeTest()");
     24 
     25 var animate = createSVGElement("animate");
     26 animate.setAttribute("id", "animation");
     27 animate.setAttribute("attributeName", "color");
     28 animate.setAttribute("from", "green");
     29 animate.setAttribute("to", "green");
     30 animate.setAttribute("begin", "0s");
     31 animate.setAttribute("dur", "3s");
     32 animate.setAttribute("fill", "freeze");
     33 animate.setAttribute("calcMode", "discrete");
     34 rect.appendChild(animate);
     35 rootSVGElement.appendChild(rect);
     36 
     37 // Setup animation test
     38 function sample1() {
     39    expectColor(rect, 255, 0, 0);
     40    assert_equals(rect.style.color, "");
     41 }
     42 
     43 function sample2() {
     44    expectColor(rect, 0, 128, 0);
     45    assert_equals(rect.style.color, "");
     46 }
     47 
     48 function sample3() {
     49    // Set 'attributeName' from 'color' to 'fill'
     50    animate.setAttribute("attributeName", "fill");
     51 }
     52 
     53 function sample4() {
     54    expectFillColor(rect, 0, 128, 0);
     55    assert_equals(rect.style.color, "");
     56    assert_equals(rect.style.fill, "");
     57 }
     58 
     59 smil_async_test((t) => {
     60    const expectedValues = [
     61        // [animationId, time, sampleCallback]
     62        ["animation", 0.0,   sample1],
     63        ["animation", 0.001, sample2],
     64        ["animation", 1.5,   sample3],
     65        ["animation", 3.0,   sample4],
     66    ];
     67 
     68    runAnimationTest(t, expectedValues);
     69 });
     70 
     71 </script>