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
92
93
94
95
96
|
<!doctype html>
<meta charset=utf-8>
<script src="../testcommon.js"></script>
<body>
<script>
'use strict';
async_test(function(t) {
var div = addDiv(t);
div.style.transform = 'translate(0px)';
window.getComputedStyle(div).transform;
div.style.transition = 'transform 100s';
div.style.transform = 'translate(10px)';
window.getComputedStyle(div).transform;
var animation = div.getAnimations()[0];
var originalReadyPromise = animation.ready;
animation.ready.then(t.step_func(function() {
assert_equals(animation.ready, originalReadyPromise,
'Ready promise is the same object when playing completes');
animation.pause();
assert_not_equals(animation.ready, originalReadyPromise,
'Ready promise object identity differs when pausing');
t.done();
}));
}, 'A new ready promise is created each time play() is called'
+ ' the animation property');
async_test(function(t) {
var div = addDiv(t);
// Set up pending transition
div.style.transform = 'translate(0px)';
window.getComputedStyle(div).transform;
div.style.transition = 'transform 100s';
div.style.transform = 'translate(10px)';
window.getComputedStyle(div).transform;
var animation = div.getAnimations()[0];
assert_equals(animation.playState, 'pending', 'Animation is initially pending');
// Set up listeners on ready promise
animation.ready.then(t.step_func(function() {
assert_unreached('ready promise was fulfilled');
})).catch(t.step_func(function(err) {
assert_equals(err.name, 'AbortError',
'ready promise is rejected with AbortError');
assert_equals(animation.playState, 'idle',
'Animation is idle after transition was cancelled');
})).then(t.step_func(function() {
t.done();
}));
// Now remove transform from transition-property and flush styles
div.style.transitionProperty = 'none';
window.getComputedStyle(div).transitionProperty;
}, 'ready promise is rejected when a transition is cancelled by updating'
+ ' transition-property');
async_test(function(t) {
var div = addDiv(t);
// Set up pending transition
div.style.marginLeft = '0px';
window.getComputedStyle(div).marginLeft;
div.style.transition = 'margin-left 100s';
div.style.marginLeft = '100px';
window.getComputedStyle(div).marginLeft;
var animation = div.getAnimations()[0];
assert_equals(animation.playState, 'pending', 'Animation is initially pending');
// Set up listeners on ready promise
animation.ready.then(t.step_func(function() {
assert_unreached('ready promise was fulfilled');
})).catch(t.step_func(function(err) {
assert_equals(err.name, 'AbortError',
'ready promise is rejected with AbortError');
assert_equals(animation.playState, 'idle',
'Animation is idle after transition was cancelled');
})).then(t.step_func(function() {
t.done();
}));
// Now update the transition to animate to something not-interpolable
div.style.marginLeft = 'auto';
window.getComputedStyle(div).marginLeft;
}, 'ready promise is rejected when a transition is cancelled by changing'
+ ' the transition property to something not interpolable');
done();
</script>
</body>
|