2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharnessreport.js"></script>
5 <div id='element'
></div>
8 var element
= document
.getElementById('element');
10 var player
= element
.animate([{left
: '0px', offset
: 0}, {left
: '100px', offset
: 1}], 10000);
11 var animation
= player
.source
;
12 assert_equals(animation
.player
, player
);
13 assert_equals(player
.currentTime
, 0);
14 player
.currentTime
= 5000;
15 assert_equals(player
.currentTime
, 5000);
16 assert_equals(player
.timeLag
, -5000);
18 player
.startTime
+= 1000;
20 assert_equals(player
.currentTime
, 4000);
23 assert_true(player
.paused
);
25 assert_false(player
.paused
);
28 assert_equals(player
.currentTime
, 10000);
29 assert_true(player
.finished
);
32 assert_equals(player
.playbackRate
, -1);
34 player
.playbackRate
= -2;
35 assert_equals(player
.playbackRate
, -2);
38 assert_equals(animation
.player
, null);
39 }, 'Player sanity tests');
42 var player
= element
.animate([{left
: '0px', offset
: 0}, {left
: '100px', offset
: 1}], {iterations
: Infinity
, duration
: 10});
43 assert_throws('INVALID_STATE_ERR', function() { player
.finish(); });
44 }, 'Player.finish() raises exception if source content end is infinity');
47 var player
= element
.animate([{left
: '0px', offset
: 0}, {left
: '100px', offset
: 1}], 10000);
48 for (var attr
of ['startTime', 'currentTime', 'playbackRate']) {
49 assert_throws(new TypeError
, function() { player
[attr
] = NaN
; }, attr
);
50 assert_throws(new TypeError
, function() { player
[attr
] = Infinity
; }, attr
);
52 }, 'Player.startTime/currentTime/playbackRate throw if passed non-finite numbers.');