|
1 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
2 <head> |
|
3 <title>Tests updated intervals</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="20" cy="20" r="15" fill="blue" id="circle"> |
|
13 <animate attributeName="cx" from="0" to="100" begin="2s" dur="4s" |
|
14 id="anim1" attributeType="XML"/> |
|
15 </circle> |
|
16 </svg> |
|
17 </div> |
|
18 <pre id="test"> |
|
19 <script class="testbody" type="text/javascript"> |
|
20 <![CDATA[ |
|
21 /** Tests for updated intervals **/ |
|
22 |
|
23 /* Global Variables */ |
|
24 SimpleTest.waitForExplicitFinish(); |
|
25 |
|
26 function main() { |
|
27 var svg = document.getElementById("svg"); |
|
28 ok(svg.animationsPaused(), "should be paused by <svg> load handler"); |
|
29 is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler"); |
|
30 |
|
31 var anim = document.getElementById("anim1"); |
|
32 |
|
33 // Check regular operation |
|
34 svg.setCurrentTime(3); |
|
35 is(anim.getStartTime(), 2, "Unexpected initial start time"); |
|
36 |
|
37 // Add an instance time before the current interval at t=1s |
|
38 anim.beginElementAt(-2); |
|
39 |
|
40 // We shouldn't change the begin time |
|
41 is(anim.getStartTime(), 2, "Start time shouldn't have changed"); |
|
42 |
|
43 // Or the end--that is, if we go to t=5.5 we should still be running |
|
44 svg.setCurrentTime(5.5); |
|
45 try { |
|
46 is(anim.getSimpleDuration(), 4, "Simple duration shouldn't have changed"); |
|
47 is(anim.getStartTime(), 2, "Start time shouldn't have changed after seek"); |
|
48 } catch (e) { |
|
49 if (e.name != "InvalidStateError" || |
|
50 e.code != DOMException.INVALID_STATE_ERR) |
|
51 throw e; |
|
52 ok(false, "Animation ended too early, even though begin time and " + |
|
53 "simple duration didn't change"); |
|
54 } |
|
55 |
|
56 SimpleTest.finish(); |
|
57 } |
|
58 |
|
59 window.addEventListener("load", main, false); |
|
60 ]]> |
|
61 </script> |
|
62 </pre> |
|
63 </body> |
|
64 </html> |