tor-browser

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

animate-marker-orient-from-angle-to-auto.html (3281B)


      1 <!doctype html>
      2 <html>
      3 <meta charset="utf-8">
      4 <title>Animate SVGMarkerElement orientAttr from an angle to auto</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 
     18 var marker = createSVGElement("marker");
     19 marker.setAttribute("id", "marker");
     20 marker.setAttribute("viewBox", "0 0 10 10");
     21 marker.setAttribute("markerWidth", "2");
     22 marker.setAttribute("markerHeight", "2");
     23 marker.setAttribute("refX", "5");
     24 marker.setAttribute("refY", "5");
     25 marker.setAttribute("markerUnits", "strokeWidth");
     26 
     27 var markerPath = createSVGElement("path");
     28 markerPath.setAttribute("fill", "blue");
     29 markerPath.setAttribute("d", "M 5 0 L 10 10 L 0 10 Z");
     30 marker.appendChild(markerPath);
     31 
     32 var defsElement = createSVGElement("defs");
     33 defsElement.appendChild(marker);
     34 rootSVGElement.appendChild(defsElement);
     35 
     36 var path = createSVGElement("path");
     37 path.setAttribute("id", "path");
     38 path.setAttribute("onclick", "executeTest()");
     39 path.setAttribute("fill", "none");
     40 path.setAttribute("stroke", "green");
     41 path.setAttribute("stroke-width", "10");
     42 path.setAttribute("marker-start", "url(#marker)");
     43 path.setAttribute("marker-end", "url(#marker)");
     44 path.setAttribute("d", "M 130 135 L 180 135 L 180 185");
     45 path.setAttribute("transform", "translate(-130, -120)");
     46 rootSVGElement.appendChild(path);
     47 
     48 var animate1 = createSVGElement("animate");
     49 animate1.setAttribute("id", "animation");
     50 animate1.setAttribute("attributeName", "orient");
     51 animate1.setAttribute("begin", "0s");
     52 animate1.setAttribute("dur", "4s");
     53 animate1.setAttribute("from", "90deg");
     54 animate1.setAttribute("to", "auto");
     55 animate1.setAttribute("fill", "freeze");
     56 marker.appendChild(animate1);
     57 
     58 // Setup animation test
     59 function sample1() {
     60    assert_approx_equals(marker.orientAngle.animVal.value, 0, epsilon);
     61    assert_equals(marker.orientAngle.baseVal.value, 0);
     62 
     63    assert_equals(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
     64    assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
     65 }
     66 
     67 function sample2() {
     68    assert_approx_equals(marker.orientAngle.animVal.value, 90, epsilon);
     69    assert_equals(marker.orientAngle.baseVal.value, 0);
     70 
     71    assert_equals(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
     72    assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
     73 }
     74 
     75 function sample3() {
     76    assert_approx_equals(marker.orientAngle.animVal.value, 0, epsilon);
     77    assert_equals(marker.orientAngle.baseVal.value, 0);
     78 
     79    assert_equals(marker.orientType.animVal, SVGMarkerElement.SVG_MARKER_ORIENT_AUTO);
     80    assert_equals(marker.orientType.baseVal, SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE);
     81 }
     82 
     83 smil_async_test((t) => {
     84    const expectedValues = [
     85        // [animationId, time, sampleCallback]
     86        ["animation", 0.0,   sample1],
     87        ["animation", 0.001, sample2],
     88        ["animation", 1.999, sample2],
     89        ["animation", 2.001, sample3],
     90        ["animation", 3.999, sample3],
     91        ["animation", 4.001, sample3]
     92    ];
     93 
     94    runAnimationTest(t, expectedValues);
     95 });
     96 
     97 </script>