1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/smil/test/test_smilFillMode.xhtml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<head> 1.6 + <title>Test for SMIL fill modes</title> 1.7 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.8 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.9 +</head> 1.10 +<body> 1.11 +<p id="display"></p> 1.12 +<div id="content" style="display: none"> 1.13 +<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px" 1.14 + onload="this.pauseAnimations()"> 1.15 + <circle cx="-100" cy="20" r="15" fill="blue" id="circle"/> 1.16 +</svg> 1.17 +</div> 1.18 +<pre id="test"> 1.19 +<script class="testbody" type="text/javascript"> 1.20 +<![CDATA[ 1.21 +/** Test for SMIL fill modes **/ 1.22 + 1.23 +/* Global Variables */ 1.24 +const svgns="http://www.w3.org/2000/svg"; 1.25 +var svg = document.getElementById("svg"); 1.26 +var circle = document.getElementById('circle'); 1.27 + 1.28 +SimpleTest.waitForExplicitFinish(); 1.29 + 1.30 +function createAnim() { 1.31 + var anim = document.createElementNS(svgns,'animate'); 1.32 + anim.setAttribute('attributeName','cx'); 1.33 + anim.setAttribute('dur','4s'); 1.34 + anim.setAttribute('begin','0s'); 1.35 + anim.setAttribute('values', '10; 20'); 1.36 + return circle.appendChild(anim); 1.37 +} 1.38 + 1.39 +function main() { 1.40 + ok(svg.animationsPaused(), "should be paused by <svg> load handler"); 1.41 + is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler"); 1.42 + 1.43 + var tests = 1.44 + [ testSetLaterA, 1.45 + testSetLaterB, 1.46 + testRemoveLater ]; 1.47 + for (var i = 0; i < tests.length; i++) { 1.48 + var anim = createAnim(); 1.49 + svg.setCurrentTime(0); 1.50 + tests[i](anim); 1.51 + anim.parentNode.removeChild(anim); 1.52 + } 1.53 + SimpleTest.finish(); 1.54 +} 1.55 + 1.56 +function checkSample(time, expectedValue) { 1.57 + svg.setCurrentTime(time); 1.58 + is(circle.cx.animVal.value, expectedValue, 1.59 + "Updated fill mode not applied to animation"); 1.60 +} 1.61 + 1.62 +// Test that we can update the fill mode after an interval has played and it 1.63 +// will be updated correctly. 1.64 +function testSetLaterA(anim) { 1.65 + checkSample(5, -100); 1.66 + anim.setAttribute('fill', 'freeze'); 1.67 + is(circle.cx.animVal.value, 20, 1.68 + "Fill not applied for retrospectively set fill mode"); 1.69 +} 1.70 + 1.71 +function testSetLaterB(anim) { 1.72 + anim.setAttribute('fill', 'freeze'); 1.73 + checkSample(5, 20); 1.74 +} 1.75 + 1.76 +function testRemoveLater(anim) { 1.77 + anim.setAttribute('fill', 'freeze'); 1.78 + checkSample(5, 20); 1.79 + anim.setAttribute('fill', 'remove'); 1.80 + is(circle.cx.animVal.value, -100, 1.81 + "Fill not removed for retrospectively set fill mode"); 1.82 +} 1.83 + 1.84 +window.addEventListener("load", main, false); 1.85 +]]> 1.86 +</script> 1.87 +</pre> 1.88 +</body> 1.89 +</html>