svgboolean-animation-1.html (2286B)
1 <!doctype html> 2 <html> 3 <meta charset="utf-8"> 4 <title>Test 'to' animation of SVGBoolean.</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 filter = createSVGElement("filter"); 21 filter.setAttribute("id", "filter"); 22 defs.appendChild(filter); 23 24 var feConvolveMatrix = createSVGElement("feConvolveMatrix"); 25 feConvolveMatrix.setAttribute("id", "effect"); 26 feConvolveMatrix.setAttribute("kernelMatrix", "0 0 0 0 1 0 0 0 0"); 27 feConvolveMatrix.setAttribute("preserveAlpha", "false"); 28 filter.appendChild(feConvolveMatrix); 29 30 var rect = createSVGElement("rect"); 31 rect.setAttribute("id", "rect"); 32 rect.setAttribute("width", "100"); 33 rect.setAttribute("height", "100"); 34 rect.setAttribute("fill", "green"); 35 rect.setAttribute("filter", "url(#filter)"); 36 rect.setAttribute("onclick", "executeTest()"); 37 rootSVGElement.appendChild(rect); 38 39 var animate = createSVGElement("animate"); 40 animate.setAttribute("id", "animation"); 41 animate.setAttribute("attributeName", "preserveAlpha"); 42 animate.setAttribute("begin", "0s"); 43 animate.setAttribute("dur", "4s"); 44 animate.setAttribute("from", "false"); 45 animate.setAttribute("to", "true"); 46 feConvolveMatrix.appendChild(animate); 47 48 // Setup animation test 49 function sample1() { 50 assert_equals(feConvolveMatrix.preserveAlpha.animVal, false); 51 assert_equals(feConvolveMatrix.preserveAlpha.baseVal, false); 52 } 53 54 function sample2() { 55 assert_equals(feConvolveMatrix.preserveAlpha.animVal, false); 56 assert_equals(feConvolveMatrix.preserveAlpha.baseVal, false); 57 } 58 59 function sample3() { 60 assert_equals(feConvolveMatrix.preserveAlpha.animVal, true); 61 assert_equals(feConvolveMatrix.preserveAlpha.baseVal, false); 62 } 63 64 smil_async_test((t) => { 65 const expectedValues = [ 66 // [animationId, time, sampleCallback] 67 ["animation", 0.0, sample1], 68 ["animation", 2.0, sample2], 69 ["animation", 3.999, sample3], 70 ["animation", 4.001, sample1] 71 ]; 72 73 runAnimationTest(t, expectedValues); 74 }); 75 76 </script>