Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / web-animations-api / w3c / get-animation-players.html
blob8e340e801059ddb16ab10738cbc5698f4a651e8c
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <div id='container'>
5 <div id='element'></div>
6 </div>
8 <script>
10 var container = document.getElementById('container');
11 var element = document.getElementById('element');
13 test(function() {
14 assert_equals(document.timeline.getAnimations().length, 0);
15 assert_equals(container.getAnimations().length, 0);
16 assert_equals(element.getAnimations().length, 0);
18 var animation = element.animate([], 1000);
19 assert_equals(document.timeline.getAnimations().length, 1);
20 assert_equals(document.timeline.getAnimations()[0], animation);
22 var animation2 = container.animate([], 1000);
23 assert_equals(document.timeline.getAnimations().length, 2);
24 assert_equals(document.timeline.getAnimations()[0], animation);
25 assert_equals(document.timeline.getAnimations()[1], animation2);
27 animation.finish();
28 assert_equals(document.timeline.getAnimations().length, 1);
29 assert_equals(document.timeline.getAnimations()[0], animation2);
31 animation2.finish();
32 assert_equals(document.timeline.getAnimations().length, 0);
33 }, 'Timeline getAnimations()');
35 test(function() {
36 assert_equals(document.timeline.getAnimations().length, 0);
37 assert_equals(container.getAnimations().length, 0);
38 assert_equals(element.getAnimations().length, 0);
40 var animation = element.animate([], 1000);
41 assert_equals(document.timeline.getAnimations().length, 1);
42 assert_equals(document.timeline.getAnimations()[0], animation);
43 assert_equals(container.getAnimations().length, 0);
44 assert_equals(element.getAnimations().length, 1);
45 assert_equals(element.getAnimations()[0], animation);
47 var animation2 = container.animate([], 1000);
48 assert_equals(document.timeline.getAnimations().length, 2);
49 assert_equals(document.timeline.getAnimations()[0], animation);
50 assert_equals(document.timeline.getAnimations()[1], animation2);
51 assert_equals(container.getAnimations().length, 1);
52 assert_equals(container.getAnimations()[0], animation2);
53 assert_equals(element.getAnimations().length, 1);
54 assert_equals(element.getAnimations()[0], animation);
56 animation.finish();
57 assert_equals(document.timeline.getAnimations().length, 1);
58 assert_equals(document.timeline.getAnimations()[0], animation2);
59 assert_equals(container.getAnimations().length, 1);
60 assert_equals(container.getAnimations()[0], animation2);
61 assert_equals(element.getAnimations().length, 0);
63 animation2.finish();
64 assert_equals(document.timeline.getAnimations().length, 0);
65 assert_equals(container.getAnimations().length, 0);
66 assert_equals(element.getAnimations().length, 0);
68 }, 'Animatable getAnimations()');
70 test(function() {
71 assert_equals(document.timeline.getAnimations().length, 0);
72 assert_equals(container.getAnimations().length, 0);
73 assert_equals(element.getAnimations().length, 0);
75 var animation = element.animate([], {duration: 1000, delay: 500});
76 assert_equals(document.timeline.getAnimations().length, 1);
77 assert_equals(document.timeline.getAnimations()[0], animation);
78 assert_equals(container.getAnimations().length, 0);
79 assert_equals(element.getAnimations().length, 1);
80 assert_equals(element.getAnimations()[0], animation);
82 animation.finish();
83 assert_equals(document.timeline.getAnimations().length, 0);
84 assert_equals(container.getAnimations().length, 0);
85 assert_equals(element.getAnimations().length, 0);
87 }, 'getAnimations() with delays');
89 test(function() {
90 assert_equals(document.timeline.getAnimations().length, 0);
91 assert_equals(container.getAnimations().length, 0);
92 assert_equals(element.getAnimations().length, 0);
94 var animation = element.animate([], {duration: 1000, delay: 500, fill: 'both'});
95 assert_equals(document.timeline.getAnimations().length, 1);
96 assert_equals(document.timeline.getAnimations()[0], animation);
97 assert_equals(container.getAnimations().length, 0);
98 assert_equals(element.getAnimations().length, 1);
99 assert_equals(element.getAnimations()[0], animation);
101 animation.finish();
102 assert_equals(document.timeline.getAnimations().length, 1);
103 // assert_equals(container.getAnimations().length, 1);
104 // assert_equals(element.getAnimations().length, 1);
106 }, 'getAnimations() - in effect animations');
108 </script>