File: getAnimations.html

package info (click to toggle)
thunderbird 1%3A68.10.0-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,754,812 kB
  • sloc: cpp: 5,411,679; javascript: 4,161,772; ansic: 2,639,702; python: 763,064; java: 346,606; xml: 266,623; asm: 265,884; sh: 117,270; lisp: 41,340; makefile: 23,560; perl: 18,042; objc: 5,277; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; cs: 879; exp: 527; awk: 495; php: 436; ruby: 221; sed: 69; csh: 27
file content (241 lines) | stat: -rw-r--r-- 8,867 bytes parent folder | download | duplicates (2)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animatable.getAnimations</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animatable-getanimations">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<script>
'use strict';

test(t => {
  const div = createDiv(t);
  assert_array_equals(div.getAnimations(), []);
}, 'Returns an empty array for an element with no animations');

test(t => {
  const div = createDiv(t);
  const animationA = div.animate(null, 100 * MS_PER_SEC);
  const animationB = div.animate(null, 100 * MS_PER_SEC);
  assert_array_equals(div.getAnimations(), [animationA, animationB]);
}, 'Returns both animations for an element with two animations');

test(t => {
  const divA = createDiv(t);
  const divB = createDiv(t);
  const animationA = divA.animate(null, 100 * MS_PER_SEC);
  const animationB = divB.animate(null, 100 * MS_PER_SEC);
  assert_array_equals(divA.getAnimations(), [animationA], 'divA');
  assert_array_equals(divB.getAnimations(), [animationB], 'divB');
}, 'Returns only the animations specific to each sibling element');

test(t => {
  const divParent = createDiv(t);
  const divChild = createDiv(t);
  divParent.appendChild(divChild);
  const animationParent = divParent.animate(null, 100 * MS_PER_SEC);
  const animationChild = divChild.animate(null, 100 * MS_PER_SEC);
  assert_array_equals(divParent.getAnimations(), [animationParent],
                      'divParent');
  assert_array_equals(divChild.getAnimations(), [animationChild], 'divChild');
}, 'Returns only the animations specific to each parent/child element');

test(t => {
  const foreignElement
    = document.createElementNS('http://example.org/test', 'test');
  document.body.appendChild(foreignElement);
  t.add_cleanup(() => {
    foreignElement.remove();
  });

  const animation = foreignElement.animate(null, 100 * MS_PER_SEC);
  assert_array_equals(foreignElement.getAnimations(), [animation]);
}, 'Returns animations for a foreign element');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);
  animation.finish();
  assert_array_equals(div.getAnimations(), []);
}, 'Does not return finished animations that do not fill forwards');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, {
    duration: 100 * MS_PER_SEC,
    fill: 'forwards',
  });
  animation.finish();
  assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns finished animations that fill forwards');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, {
    duration: 100 * MS_PER_SEC,
    delay: 100 * MS_PER_SEC,
  });
  assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns animations yet to reach their active phase');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);
  animation.playbackRate = -1;
  assert_array_equals(div.getAnimations(), []);
}, 'Does not return reversed finished animations that do not fill backwards');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, {
    duration: 100 * MS_PER_SEC,
    fill: 'backwards',
  });
  animation.playbackRate = -1;
  assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns reversed finished animations that fill backwards');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);
  animation.playbackRate = -1;
  animation.currentTime = 200 * MS_PER_SEC;
  assert_array_equals(div.getAnimations(), [animation]);
}, 'Returns reversed animations yet to reach their active phase');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, {
    duration: 100 * MS_PER_SEC,
    delay: 100 * MS_PER_SEC,
  });
  animation.playbackRate = 0;
  assert_array_equals(div.getAnimations(), []);
}, 'Does not return animations with zero playback rate in before phase');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);
  animation.finish();
  animation.playbackRate = 0;
  animation.currentTime = 200 * MS_PER_SEC;
}, 'Does not return animations with zero playback rate in after phase');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);

  animation.finish();
  assert_array_equals(div.getAnimations(), [],
                      'Animation should not be returned when it is finished');

  animation.effect.updateTiming({
    duration: animation.effect.getTiming().duration + 100 * MS_PER_SEC,
  });
  assert_array_equals(div.getAnimations(), [animation],
                      'Animation should be returned after extending the'
                      + ' duration');

  animation.effect.updateTiming({ duration: 0 });
  assert_array_equals(div.getAnimations(), [],
                      'Animation should not be returned after setting the'
                      + ' duration to zero');
}, 'Returns animations based on dynamic changes to individual'
   + ' animations\' duration');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);

  animation.effect.updateTiming({ endDelay: -200 * MS_PER_SEC });
  assert_array_equals(div.getAnimations(), [],
                      'Animation should not be returned after setting a'
                      + ' negative end delay such that the end time is less'
                      + ' than the current time');

  animation.effect.updateTiming({ endDelay: 100 * MS_PER_SEC });
  assert_array_equals(div.getAnimations(), [animation],
                      'Animation should be returned after setting a positive'
                      + ' end delay such that the end time is more than the'
                      + ' current time');
}, 'Returns animations based on dynamic changes to individual'
   + ' animations\' end delay');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null, 100 * MS_PER_SEC);

  animation.finish();
  assert_array_equals(div.getAnimations(), [],
                      'Animation should not be returned when it is finished');

  animation.effect.updateTiming({ iterations: 10 });
  assert_array_equals(div.getAnimations(), [animation],
                      'Animation should be returned after inreasing the'
                      + ' number of iterations');

  animation.effect.updateTiming({ iterations: 0 });
  assert_array_equals(div.getAnimations(), [],
                      'Animations should not be returned after setting the'
                      + ' iteration count to zero');

  animation.effect.updateTiming({ iterations: Infinity });
  assert_array_equals(div.getAnimations(), [animation],
                      'Animation should be returned after inreasing the'
                      + ' number of iterations to infinity');
}, 'Returns animations based on dynamic changes to individual'
   + ' animations\' iteration count');

test(t => {
  const div = createDiv(t);
  const animation = div.animate(null,
                                { duration: 100 * MS_PER_SEC,
                                  delay: 50 * MS_PER_SEC,
                                  endDelay: -50 * MS_PER_SEC });

  assert_array_equals(div.getAnimations(), [animation],
                      'Animation should be returned at during delay phase');

  animation.currentTime = 50 * MS_PER_SEC;
  assert_array_equals(div.getAnimations(), [animation],
                      'Animation should be returned after seeking to the start'
                      + ' of the active interval');

  animation.currentTime = 100 * MS_PER_SEC;
  assert_array_equals(div.getAnimations(), [],
                      'Animation should not be returned after seeking to the'
                      + ' clipped end of the active interval');
}, 'Returns animations based on dynamic changes to individual'
   + ' animations\' current time');

promise_test(async t => {
  const div = createDiv(t);
  const watcher = EventWatcher(t, div, 'transitionrun');

  // Create a covering animation to prevent transitions from firing after
  // calling getAnimations().
  const coveringAnimation = new Animation(
    new KeyframeEffect(div, { opacity: [0, 1] }, 100 * MS_PER_SEC)
  );

  // Setup transition start point.
  div.style.transition = 'opacity 100s';
  getComputedStyle(div).opacity;

  // Update specified style but don't flush style.
  div.style.opacity = '0.5';

  // Fetch animations
  div.getAnimations();

  // Play the covering animation to ensure that only the call to
  // getAnimations() has a chance to trigger transitions.
  coveringAnimation.play();

  // If getAnimations() flushed style, we should get a transitionrun event.
  await watcher.wait_for('transitionrun');
}, 'Triggers a style change event');

</script>
</body>