dom/smil/test/test_smilFillMode.xhtml

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:9e7d171b815a
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <head>
3 <title>Test for SMIL fill modes</title>
4 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
6 </head>
7 <body>
8 <p id="display"></p>
9 <div id="content" style="display: none">
10 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="120px" height="120px"
11 onload="this.pauseAnimations()">
12 <circle cx="-100" cy="20" r="15" fill="blue" id="circle"/>
13 </svg>
14 </div>
15 <pre id="test">
16 <script class="testbody" type="text/javascript">
17 <![CDATA[
18 /** Test for SMIL fill modes **/
19
20 /* Global Variables */
21 const svgns="http://www.w3.org/2000/svg";
22 var svg = document.getElementById("svg");
23 var circle = document.getElementById('circle');
24
25 SimpleTest.waitForExplicitFinish();
26
27 function createAnim() {
28 var anim = document.createElementNS(svgns,'animate');
29 anim.setAttribute('attributeName','cx');
30 anim.setAttribute('dur','4s');
31 anim.setAttribute('begin','0s');
32 anim.setAttribute('values', '10; 20');
33 return circle.appendChild(anim);
34 }
35
36 function main() {
37 ok(svg.animationsPaused(), "should be paused by <svg> load handler");
38 is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
39
40 var tests =
41 [ testSetLaterA,
42 testSetLaterB,
43 testRemoveLater ];
44 for (var i = 0; i < tests.length; i++) {
45 var anim = createAnim();
46 svg.setCurrentTime(0);
47 tests[i](anim);
48 anim.parentNode.removeChild(anim);
49 }
50 SimpleTest.finish();
51 }
52
53 function checkSample(time, expectedValue) {
54 svg.setCurrentTime(time);
55 is(circle.cx.animVal.value, expectedValue,
56 "Updated fill mode not applied to animation");
57 }
58
59 // Test that we can update the fill mode after an interval has played and it
60 // will be updated correctly.
61 function testSetLaterA(anim) {
62 checkSample(5, -100);
63 anim.setAttribute('fill', 'freeze');
64 is(circle.cx.animVal.value, 20,
65 "Fill not applied for retrospectively set fill mode");
66 }
67
68 function testSetLaterB(anim) {
69 anim.setAttribute('fill', 'freeze');
70 checkSample(5, 20);
71 }
72
73 function testRemoveLater(anim) {
74 anim.setAttribute('fill', 'freeze');
75 checkSample(5, 20);
76 anim.setAttribute('fill', 'remove');
77 is(circle.cx.animVal.value, -100,
78 "Fill not removed for retrospectively set fill mode");
79 }
80
81 window.addEventListener("load", main, false);
82 ]]>
83 </script>
84 </pre>
85 </body>
86 </html>

mercurial