summaryrefslogtreecommitdiffstats
path: root/dom/animation/test/css-transitions/file_setting-effect.html
blob: c61877194ef505a79f7e1d2e177f8f7be535eb90 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!doctype html>
<meta charset=utf-8>
<script src='../testcommon.js'></script>
<body>
<script>
'use strict';

promise_test(function(t) {
  var div = addDiv(t);
  div.style.left = '0px';

  div.style.transition = 'left 100s';
  flushComputedStyle(div);
  div.style.left = '100px';

  var transition = div.getAnimations()[0];
  return transition.ready.then(function() {
    transition.currentTime = 50 * MS_PER_SEC;
    transition.effect = null;
    assert_equals(transition.transitionProperty, 'left');
    assert_equals(transition.playState, 'finished');
    assert_equals(window.getComputedStyle(div).left, '100px');
  });
}, 'Test for removing a transition effect');

promise_test(function(t) {
  var div = addDiv(t);
  div.style.left = '0px';

  div.style.transition = 'left 100s';
  flushComputedStyle(div);
  div.style.left = '100px';

  var transition = div.getAnimations()[0];
  return transition.ready.then(function() {
    transition.currentTime = 50 * MS_PER_SEC;
    transition.effect = new KeyframeEffect(div,
                                           { marginLeft: [ '0px' , '100px'] },
                                           100 * MS_PER_SEC);
    assert_equals(transition.transitionProperty, 'left');
    assert_equals(transition.playState, 'running');
    assert_equals(window.getComputedStyle(div).left, '100px');
    assert_equals(window.getComputedStyle(div).marginLeft, '50px');
  });
}, 'Test for replacing the transition effect by a new keyframe effect');

promise_test(function(t) {
  var div = addDiv(t);
  div.style.left = '0px';
  div.style.width = '0px';

  div.style.transition = 'left 100s';
  flushComputedStyle(div);
  div.style.left = '100px';

  var transition = div.getAnimations()[0];
  return transition.ready.then(function() {
    transition.currentTime = 50 * MS_PER_SEC;
    transition.effect = new KeyframeEffect(div,
                                           { marginLeft: [ '0px' , '100px'] },
                                           20 * MS_PER_SEC);
    assert_equals(transition.playState, 'finished');
  });
}, 'Test for setting a new keyframe effect with a shorter duration');

promise_test(function(t) {
  var div = addDiv(t);
  div.style.left = '0px';
  div.style.width = '0px';

  div.style.transition = 'left 100s';
  flushComputedStyle(div);
  div.style.left = '100px';

  var transition = div.getAnimations()[0];
  assert_equals(transition.playState, 'pending');

  transition.effect = new KeyframeEffect(div,
                                         { marginLeft: [ '0px' , '100px'] },
                                         100 * MS_PER_SEC);
  assert_equals(transition.transitionProperty, 'left');
  assert_equals(transition.playState, 'pending');

  return transition.ready.then(function() {
    assert_equals(transition.playState, 'running');
  });
}, 'Test for setting a new keyframe effect to a pending transition');

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