1<!DOCTYPE html>
2<script src="testharness/testharness.js"></script>
3<script src="testharness/testharnessreport.js"></script>
4
5<div id='container'>
6    <div id='element'></div>
7</div>
8
9<script>
10
11var container = document.getElementById('container');
12var element = document.getElementById('element');
13
14test(function() {
15    assert_equals(document.timeline.getAnimationPlayers().length, 0);
16    assert_equals(container.getAnimationPlayers().length, 0);
17    assert_equals(element.getAnimationPlayers().length, 0);
18
19    var player = element.animate([], 1000);
20    assert_equals(document.timeline.getAnimationPlayers().length, 1);
21    assert_equals(document.timeline.getAnimationPlayers()[0], player);
22
23    var player2 = container.animate([], 1000);
24    assert_equals(document.timeline.getAnimationPlayers().length, 2);
25    assert_equals(document.timeline.getAnimationPlayers()[0], player);
26    assert_equals(document.timeline.getAnimationPlayers()[1], player2);
27
28    player.finish();
29    assert_equals(document.timeline.getAnimationPlayers().length, 1);
30    assert_equals(document.timeline.getAnimationPlayers()[0], player2);
31
32    player2.finish();
33    assert_equals(document.timeline.getAnimationPlayers().length, 0);
34}, 'Timeline getAnimationPlayers()');
35
36test(function() {
37    assert_equals(document.timeline.getAnimationPlayers().length, 0);
38    assert_equals(container.getAnimationPlayers().length, 0);
39    assert_equals(element.getAnimationPlayers().length, 0);
40
41    var player = element.animate([], 1000);
42    assert_equals(document.timeline.getAnimationPlayers().length, 1);
43    assert_equals(document.timeline.getAnimationPlayers()[0], player);
44    assert_equals(container.getAnimationPlayers().length, 0);
45    assert_equals(element.getAnimationPlayers().length, 1);
46    assert_equals(element.getAnimationPlayers()[0], player);
47
48    var player2 = container.animate([], 1000);
49    assert_equals(document.timeline.getAnimationPlayers().length, 2);
50    assert_equals(document.timeline.getAnimationPlayers()[0], player);
51    assert_equals(document.timeline.getAnimationPlayers()[1], player2);
52    assert_equals(container.getAnimationPlayers().length, 1);
53    assert_equals(container.getAnimationPlayers()[0], player2);
54    assert_equals(element.getAnimationPlayers().length, 1);
55    assert_equals(element.getAnimationPlayers()[0], player);
56
57    player.finish();
58    assert_equals(document.timeline.getAnimationPlayers().length, 1);
59    assert_equals(document.timeline.getAnimationPlayers()[0], player2);
60    assert_equals(container.getAnimationPlayers().length, 1);
61    assert_equals(container.getAnimationPlayers()[0], player2);
62    assert_equals(element.getAnimationPlayers().length, 0);
63
64    player2.finish();
65    assert_equals(document.timeline.getAnimationPlayers().length, 0);
66    assert_equals(container.getAnimationPlayers().length, 0);
67    assert_equals(element.getAnimationPlayers().length, 0);
68
69}, 'Animatable getAnimationPlayers()');
70
71test(function() {
72    assert_equals(document.timeline.getAnimationPlayers().length, 0);
73    assert_equals(container.getAnimationPlayers().length, 0);
74    assert_equals(element.getAnimationPlayers().length, 0);
75
76    var player = element.animate([], {duration: 1000, delay: 500});
77    assert_equals(document.timeline.getAnimationPlayers().length, 1);
78    assert_equals(document.timeline.getAnimationPlayers()[0], player);
79    assert_equals(container.getAnimationPlayers().length, 0);
80    assert_equals(element.getAnimationPlayers().length, 1);
81    assert_equals(element.getAnimationPlayers()[0], player);
82
83    player.finish();
84    assert_equals(document.timeline.getAnimationPlayers().length, 0);
85    assert_equals(container.getAnimationPlayers().length, 0);
86    assert_equals(element.getAnimationPlayers().length, 0);
87
88}, 'getAnimationPlayers() with delays');
89
90</script>
91