summaryrefslogtreecommitdiff
path: root/dom/animation/test/css-transitions/file_animation-finished.html
blob: 2f6bcf47d8a6152ef88611aa10aa2319c6bd8850 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<meta charset=utf-8>
<script src="../testcommon.js"></script>
<style>

.animated-div {
  margin-left: 100px;
  transition: margin-left 1000s linear 1000s;
}

</style>
<body>
<script>

'use strict';

const ANIM_DELAY_MS = 1000000; // 1000s
const ANIM_DUR_MS = 1000000; // 1000s

async_test(function(t) {
  var div = addDiv(t, {'class': 'animated-div'});
  flushComputedStyle(div);
  div.style.marginLeft = '200px'; // initiate transition

  var animation = div.getAnimations()[0];

  animation.finish();

  animation.finished.then(t.step_func(function() {
    animation.play();
    assert_equals(animation.currentTime, 0,
                  'Replaying a finished transition should reset its ' +
                  'currentTime');
    t.done();
  }));
}, 'Test restarting a finished transition');

async_test(function(t) {
  var div = addDiv(t, {'class': 'animated-div'});
  flushComputedStyle(div);
  div.style.marginLeft = '200px'; // initiate transition

  var animation = div.getAnimations()[0];

  animation.ready.then(function() {
    animation.playbackRate = -1;
    return animation.finished;
  }).then(t.step_func(function() {
    animation.play();
    // FIXME: once animation.effect.computedTiming.endTime is available (bug
    // 1108055) we should use that here.
    assert_equals(animation.currentTime, ANIM_DELAY_MS + ANIM_DUR_MS,
                  'Replaying a finished reversed transition should reset ' +
                  'its currentTime to the end of the effect');
    t.done();
  }));
}, 'Test restarting a reversed finished transition');

done();
</script>
</body>