svgenum-animation-2.html (2766B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>Test EdgeModeType enumeration animations</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 defs = createSVGElement("defs"); 18 rootSVGElement.appendChild(defs); 19 20 var convolveMatrix = createSVGElement("feConvolveMatrix"); 21 convolveMatrix.setAttribute("in", "SourceGraphic"); 22 convolveMatrix.setAttribute("order", "3"); 23 convolveMatrix.setAttribute("kernelMatrix", "3 0 3 0 0 0 3 0 3"); 24 convolveMatrix.setAttribute("targetX", "0"); 25 convolveMatrix.setAttribute("edgeMode", "wrap"); 26 27 var filter = createSVGElement("filter"); 28 filter.setAttribute("id", "filter"); 29 filter.setAttribute("filterUnits", "userSpaceOnUse"); 30 filter.setAttribute("x", "0"); 31 filter.setAttribute("y", "0"); 32 filter.setAttribute("width", "200"); 33 filter.setAttribute("height", "200"); 34 filter.appendChild(convolveMatrix); 35 defs.appendChild(filter); 36 37 var rect = createSVGElement("rect"); 38 rect.setAttribute("id", "rect"); 39 rect.setAttribute("width", "100"); 40 rect.setAttribute("height", "100"); 41 rect.setAttribute("filter", "url(#filter)"); 42 rect.setAttribute("onclick", "executeTest()"); 43 rootSVGElement.appendChild(rect); 44 45 var animate = createSVGElement("animate"); 46 animate.setAttribute("id", "animation"); 47 animate.setAttribute("attributeName", "edgeMode"); 48 animate.setAttribute("begin", "0s"); 49 animate.setAttribute("dur", "4s"); 50 animate.setAttribute("values", "duplicate;none"); 51 convolveMatrix.appendChild(animate); 52 53 // Setup animation test 54 function sample1() { 55 assert_equals(convolveMatrix.edgeMode.animVal, SVGFEConvolveMatrixElement.SVG_EDGEMODE_WRAP); 56 assert_equals(convolveMatrix.edgeMode.baseVal, SVGFEConvolveMatrixElement.SVG_EDGEMODE_WRAP); 57 } 58 59 function sample2() { 60 assert_equals(convolveMatrix.edgeMode.animVal, SVGFEConvolveMatrixElement.SVG_EDGEMODE_DUPLICATE); 61 assert_equals(convolveMatrix.edgeMode.baseVal, SVGFEConvolveMatrixElement.SVG_EDGEMODE_WRAP); 62 } 63 64 function sample3() { 65 assert_equals(convolveMatrix.edgeMode.animVal, SVGFEConvolveMatrixElement.SVG_EDGEMODE_NONE); 66 assert_equals(convolveMatrix.edgeMode.baseVal, SVGFEConvolveMatrixElement.SVG_EDGEMODE_WRAP); 67 } 68 69 smil_async_test((t) => { 70 const expectedValues = [ 71 // [animationId, time, sampleCallback] 72 ["animation", 0.0, sample1], 73 ["animation", 0.001, sample2], 74 ["animation", 1.999, sample2], 75 ["animation", 2.001, sample3], 76 ["animation", 3.999, sample3], 77 ["animation", 4.001, sample1] 78 ]; 79 80 runAnimationTest(t, expectedValues); 81 }); 82 83 </script>