tor-browser

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

animate-path-animation-Mm-Aa-Z.tentative.html (2646B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>Path animation where coordinate modes of start and end differ (M-m, A-a and Z)</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/resources/SVGAnimationTestCase-testharness.js"></script>
      7 <script src="support/animated-path-helpers.js"></script>
      8 <svg></svg>
      9 <script>
     10 var rootSVGElement = document.querySelector("svg");
     11 
     12 // Setup test document
     13 var path = createSVGElement("path");
     14 path.setAttribute("id", "path");
     15 path.setAttribute("d", 'M -80 40 A 150 160 30 1 1 0 100 M 40 60 A 170 180 90 1 1 300 200 Z M 300 100');
     16 path.setAttribute("fill", "green");
     17 path.setAttribute("transform", "translate(50, 50)");
     18 
     19 var animate = createSVGElement("animate");
     20 animate.setAttribute("id", "animation");
     21 animate.setAttribute("attributeName", "d");
     22 animate.setAttribute("from", 'M -80 40 A 150 160 30 1 1 0 100 M 40 60 A 170 180 90 1 1 300 200 Z M 300 100');
     23 animate.setAttribute("to", 'm -70 30 a 160 170 60 1 1 60 40 m 120 70 a 180 190 120 1 1 100 150 Z m 120 -60');
     24 animate.setAttribute("begin", "0s");
     25 animate.setAttribute("dur", "4s");
     26 path.appendChild(animate);
     27 rootSVGElement.appendChild(path);
     28 
     29 // Setup animation test
     30 function sample1() {
     31  // Check initial/end conditions
     32  assert_animated_path_equals(
     33    path, "M -80 40 A 150 160 30 1 1 0 100 M 40 60 A 170 180 90 1 1 300 200 Z M 300 100");
     34 }
     35 
     36 function sample2() {
     37  assert_animated_path_in_array(path, [
     38    "m -77.5 37.5 a 152.5 162.5 37.5 1 1 75 55 m 60 -12.5 a 172.5 182.5 97.5 1 1 220 142.5 Z m 225 15",
     39    "M -77.5 37.5 A 152.5 162.5 37.5 1 1 -2.5 92.5 M 57.5 80 A 172.5 182.5 97.5 1 1 277.5 222.5 Z M 282.5 95",
     40  ]);
     41 }
     42 
     43 function sample3() {
     44  assert_animated_path_in_array(path, [
     45    "m -72.5 32.5 a 157.5 167.5 52.5 1 1 65 45 m 100 42.5 a 177.5 187.5 112.5 1 1 140 147.5 Z m 155 -35",
     46    "M -72.5 32.5 A 157.5 167.5 52.5 1 1 -7.5 77.5 M 92.5 120 A 177.5 187.5 112.5 1 1 232.5 267.5 Z M 247.5 85",
     47  ]);
     48 }
     49 
     50 function sample4() {
     51  assert_animated_path_in_array(path, [
     52    "m -70.0025 30.0025 a 159.997 169.997 59.9925 1 1 60.005 40.005 m 119.98 69.9725 a 179.997 189.997 119.993 1 1 100.04 149.998 Z m 120.035 -59.975",
     53    "M -70 30 A 160 170 59.99 1 1 -10 70.01 M 109.98 139.98 A 180 190 119.99 1 1 210.02 289.98 Z M 230.02 80",
     54  ]);
     55 }
     56 
     57 smil_async_test(t => {
     58  const expectedValues = [
     59    // [animationId, time, sampleCallback]
     60    ["animation", 0.0,   sample1],
     61    ["animation", 1.0,   sample2],
     62    ["animation", 3.0,   sample3],
     63    ["animation", 3.999, sample4],
     64    ["animation", 4.001, sample1]
     65  ];
     66  runAnimationTest(t, expectedValues);
     67 });
     68 </script>