2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
10 var element = document.getElementById('e');
11 var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
14 var animation = new Animation(element, keyframes);
15 assert_equals(animation.localTime, null);
16 assert_equals(animation.currentIteration, null);
17 }, 'TimedItem.localTime and TimedItem.currentIteration are null when animation is not associated with a Player');
20 var animation = element.animate(keyframes, {fill: 'both', duration: 2, iterations: 3});
21 animation.player.currentTime = -1;
22 assert_equals(animation.localTime, -1);
23 assert_equals(animation.currentIteration, 0);
24 animation.player.currentTime = 1;
25 assert_equals(animation.localTime, 1);
26 assert_equals(animation.currentIteration, 0);
27 animation.player.currentTime = 5;
28 assert_equals(animation.localTime, 5);
29 assert_equals(animation.currentIteration, 2);
30 animation.player.currentTime = 7;
31 assert_equals(animation.localTime, 7);
32 assert_equals(animation.currentIteration, 2);
33 }, 'TimedItem.localTime and TimedItem.currentIteration return reasonable values when an animation is in effect');
36 var animation = element.animate(keyframes);
37 animation.player.currentTime = -1;
38 assert_equals(animation.currentIteration, null);
39 animation.player.currentTime = 1;
40 assert_equals(animation.currentIteration, null);
41 }, 'TimedItem.currentIteration is null when animation is not in effect');
44 var animation = new Animation(element, keyframes, 2);
45 assert_equals(animation.startTime, 0);
46 assert_equals(animation.endTime, 2);
47 assert_equals(animation.duration, 2);
48 assert_equals(animation.activeDuration, 2);
49 }, 'TimedItem startTime, endTime, duration, activeDuration are sensible for a simple animation');
52 var animation = new Animation(element, keyframes, {duration: 3, iterations: 4, delay: 5});
53 assert_equals(animation.startTime, 0);
54 assert_equals(animation.endTime, 17);
55 assert_equals(animation.duration, 3);
56 assert_equals(animation.activeDuration, 12);
57 }, 'TimedItem startTime, endTime, duration, activeDuration are sensible for animations with delays and iterations');
60 var animation = new Animation(element, keyframes, {delay: 1});
61 assert_equals(animation.duration, 0);
62 }, 'TimedItem duration is calculated when no duration is specified');