Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / web-animations-api / timed-item.html
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4
5 <body>
6     <div id='e'></div>
7 </body>
8
9 <script>
10 var element = document.getElementById('e');
11 var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
12
13 test(function() {
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');
18
19 test(function() {
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');
34
35 test(function() {
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');
42
43 test(function() {
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');
50
51 test(function() {
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');
58
59 test(function() {
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');
63
64 </script>