1suite('timing', function() {
2  setup(function() {
3    webAnimations1.timeline._players = [];
4  });
5
6  test('pause and scrub', function() {
7    var player = document.body.animate([], { duration: 1000 });
8    player.pause();
9
10    player.currentTime = 500;
11    assert.equal(player.currentTime, 500);
12  });
13
14  test('pause, scrub and play', function() {
15    var target = document.createElement('div');
16    document.body.appendChild(target);
17
18    var player = target.animate([
19      { background: 'blue' },
20      { background: 'red' }
21    ], { duration: 1000 });
22    tick(100);
23    player.pause();
24
25    player.currentTime = 200;
26    // http://www.w3.org/TR/web-animations/#the-current-time-of-a-player
27    // currentTime should now mean 'hold time' - this allows scrubbing.
28    assert.equal(player.currentTime, 200);
29    player.play();
30
31    tick(200);
32    tick(300);
33    assert.equal(player.currentTime, 300);
34    assert.equal(player.startTime, 0);
35  });
36
37  test('sanity-check NaN timing', function() {
38    // This has no actual tests, but will infinite loop without fix.
39
40    var player = document.body.animate([], {
41      duration: 2000,
42      easing: 'ease-in'  // fails only with cubic easing, not linear
43    });
44    tick(100);
45    player.currentTime = NaN;
46    tick(200);
47
48    player = document.body.animate([], { duration: NaN, easing: 'ease-out' });
49    tick(300);
50  });
51
52  test('can set fill:none on group', function() {
53    var timing = webAnimationsShared.makeTiming({fill: 'none'}, true);
54    assert.equal(timing.fill, 'none');
55  });
56});
57