2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharnessreport.js"></script>
6 function assert_unresolved(value
) {
7 assert_equals(value
, null);
10 function idlePlayer() {
11 var player
= document
.documentElement
.animate([], 100000);
16 function runningPlayer() {
17 var player
= document
.documentElement
.animate([], 100000);
18 player
.startTime
= document
.timeline
.currentTime
;
22 function pendingStartTimePlayer() {
23 var player
= document
.documentElement
.animate([], 100000);
27 function pendingStartTimeAndCurrentTimePlayer() {
28 var player
= document
.documentElement
.animate([], 100000);
34 function pausedPlayer() {
35 var player
= document
.documentElement
.animate([], 100000);
37 player
.currentTime
= 0;
41 function finishedPlayer() {
42 var player
= document
.documentElement
.animate([], 100000);
48 var player
= idlePlayer();
49 assert_unresolved(player
.startTime
);
50 assert_unresolved(player
.currentTime
);
51 assert_equals(player
.playState
, 'idle');
55 var player
= pendingStartTimePlayer();
56 assert_unresolved(player
.startTime
);
57 assert_equals(player
.currentTime
, 0);
58 assert_equals(player
.playState
, 'pending');
59 }, "pending startTime");
62 var player
= pendingStartTimeAndCurrentTimePlayer();
63 assert_unresolved(player
.startTime
);
64 assert_unresolved(player
.currentTime
);
65 assert_equals(player
.playState
, 'pending');
66 }, "pending startTime and currentTime");
69 var player
= runningPlayer();
70 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
71 assert_equals(player
.currentTime
, 0);
72 assert_equals(player
.playState
, 'running');
76 var player
= pausedPlayer();
77 assert_unresolved(player
.startTime
);
78 assert_equals(player
.currentTime
, 0);
79 assert_equals(player
.playState
, 'paused');
83 var player
= finishedPlayer();
84 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
85 assert_equals(player
.currentTime
, 100000);
86 assert_equals(player
.playState
, 'finished');
90 var player
= idlePlayer();
92 assert_unresolved(player
.startTime
);
93 assert_equals(player
.currentTime
, 0);
94 assert_equals(player
.playState
, 'pending');
98 var player
= idlePlayer();
100 assert_unresolved(player
.startTime
);
101 assert_unresolved(player
.currentTime
);
102 assert_equals(player
.playState
, 'idle');
103 }, "idle -> pause()");
106 var player
= idlePlayer();
108 assert_unresolved(player
.startTime
);
109 assert_unresolved(player
.currentTime
);
110 assert_equals(player
.playState
, 'idle');
111 }, "idle -> cancel()");
114 var player
= idlePlayer();
116 assert_unresolved(player
.startTime
);
117 assert_unresolved(player
.currentTime
);
118 assert_equals(player
.playState
, 'idle');
119 }, "idle -> finish()");
122 var player
= idlePlayer();
124 assert_unresolved(player
.startTime
);
125 assert_equals(player
.currentTime
, 100000);
126 assert_equals(player
.playState
, 'pending');
127 }, "idle -> reverse()");
130 var player
= idlePlayer();
131 player
.currentTime
= 1000;
132 assert_unresolved(player
.startTime
);
133 assert_unresolved(player
.currentTime
);
134 assert_equals(player
.playState
, 'idle');
135 }, "idle -> set currentTime");
138 var player
= idlePlayer();
139 player
.startTime
= 1000;
140 assert_unresolved(player
.startTime
);
141 assert_unresolved(player
.currentTime
);
142 assert_equals(player
.playState
, 'idle');
143 }, "idle -> set startTime");
146 var player
= pendingStartTimePlayer();
148 assert_unresolved(player
.startTime
);
149 assert_equals(player
.currentTime
, 0);
150 assert_equals(player
.playState
, 'pending');
151 }, "pending startTime -> play()");
154 var player
= pendingStartTimePlayer();
156 assert_unresolved(player
.startTime
);
157 assert_unresolved(player
.currentTime
);
158 assert_equals(player
.playState
, 'pending');
159 }, "pending startTime -> pause()");
162 var player
= pendingStartTimePlayer();
164 assert_unresolved(player
.startTime
);
165 assert_unresolved(player
.currentTime
);
166 assert_equals(player
.playState
, 'idle');
167 }, "pending startTime -> cancel()");
170 var player
= pendingStartTimePlayer();
172 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
173 assert_equals(player
.currentTime
, 100000);
174 assert_equals(player
.playState
, 'finished');
175 }, "pending startTime -> finish()");
178 var player
= pendingStartTimePlayer();
180 assert_unresolved(player
.startTime
);
181 assert_equals(player
.currentTime
, 100000);
182 assert_equals(player
.playState
, 'pending');
183 }, "pending startTime -> reverse()");
186 var player
= pendingStartTimePlayer();
187 player
.currentTime
= 1000;
188 assert_unresolved(player
.startTime
);
189 assert_equals(player
.currentTime
, 1000);
190 assert_equals(player
.playState
, 'pending');
191 }, "pending startTime -> set currentTime");
194 var player
= pendingStartTimePlayer();
195 player
.startTime
= document
.timeline
.currentTime
- 1000;
196 assert_equals(player
.startTime
, document
.timeline
.currentTime
- 1000);
197 assert_equals(player
.currentTime
, 1000);
198 assert_equals(player
.playState
, 'running');
199 }, "pending startTime -> set startTime");
202 var player
= pendingStartTimeAndCurrentTimePlayer();
204 assert_unresolved(player
.startTime
);
205 assert_unresolved(player
.currentTime
);
206 assert_equals(player
.playState
, 'pending');
207 }, "pending startTime & currentTime -> play()");
210 var player
= pendingStartTimeAndCurrentTimePlayer();
212 assert_unresolved(player
.startTime
);
213 assert_unresolved(player
.currentTime
);
214 assert_equals(player
.playState
, 'pending');
215 }, "pending startTime & currentTime -> pause()");
218 var player
= pendingStartTimeAndCurrentTimePlayer();
220 assert_unresolved(player
.startTime
);
221 assert_unresolved(player
.currentTime
);
222 assert_equals(player
.playState
, 'idle');
223 }, "pending startTime & currentTime -> cancel()");
226 var player
= pendingStartTimeAndCurrentTimePlayer();
228 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
229 assert_equals(player
.currentTime
, 100000);
230 assert_equals(player
.playState
, 'finished');
231 }, "pending startTime & currentTime -> finish()");
234 var player
= pendingStartTimeAndCurrentTimePlayer();
236 assert_unresolved(player
.startTime
);
237 assert_unresolved(player
.currentTime
);
238 assert_equals(player
.playState
, 'pending');
239 }, "pending startTime & currentTime -> reverse()");
242 var player
= pendingStartTimeAndCurrentTimePlayer();
243 player
.currentTime
= 1000;
244 assert_unresolved(player
.startTime
);
245 assert_equals(player
.currentTime
, 1000);
246 assert_equals(player
.playState
, 'pending');
247 }, "pending startTime & currentTime -> set currentTime");
250 var player
= pendingStartTimeAndCurrentTimePlayer();
251 player
.startTime
= document
.timeline
.currentTime
;
252 assert_equals(player
.startTime
, document
.timeline
.currentTime
);
253 assert_equals(player
.currentTime
, 0);
254 assert_equals(player
.playState
, 'running');
255 }, "pending startTime & currentTime -> set startTime");
258 var player
= runningPlayer();
259 var startTime
= player
.startTime
;
260 var currentTime
= player
.currentTime
;
262 assert_equals(player
.startTime
, startTime
);
263 assert_equals(player
.currentTime
, currentTime
);
264 assert_equals(player
.playState
, 'running');
265 }, "running -> play()");
268 var player
= runningPlayer();
270 assert_unresolved(player
.startTime
);
271 assert_unresolved(player
.currentTime
);
272 assert_equals(player
.playState
, 'pending');
273 }, "running -> pause()");
276 var player
= runningPlayer();
278 assert_unresolved(player
.startTime
);
279 assert_unresolved(player
.currentTime
);
280 assert_equals(player
.playState
, 'idle');
281 }, "running -> cancel()");
284 var player
= runningPlayer();
286 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
287 assert_equals(player
.currentTime
, 100000);
288 assert_equals(player
.playState
, 'finished');
289 }, "running -> finish()");
292 var player
= runningPlayer();
294 assert_unresolved(player
.startTime
);
295 assert_unresolved(player
.currentTime
);
296 assert_equals(player
.playState
, 'pending');
297 }, "running -> reverse()");
300 var player
= runningPlayer();
301 player
.currentTime
= 1000;
302 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
303 assert_equals(player
.currentTime
, 1000);
304 assert_equals(player
.playState
, 'running');
305 }, "running -> set currentTime");
308 var player
= runningPlayer();
309 player
.startTime
= document
.timeline
.currentTime
- 1000;
310 assert_equals(player
.startTime
, document
.timeline
.currentTime
- 1000);
311 assert_equals(player
.currentTime
, 1000);
312 assert_equals(player
.playState
, 'running');
313 }, "running -> set startTime");
316 var player
= pausedPlayer();
318 assert_unresolved(player
.startTime
);
319 assert_equals(player
.currentTime
, 0);
320 assert_equals(player
.playState
, 'pending');
321 }, "paused -> play()");
324 var player
= pausedPlayer();
326 assert_unresolved(player
.startTime
);
327 assert_equals(player
.currentTime
, 0);
328 assert_equals(player
.playState
, 'paused');
329 }, "paused -> pause()");
332 var player
= pausedPlayer();
334 assert_unresolved(player
.startTime
);
335 assert_unresolved(player
.currentTime
);
336 assert_equals(player
.playState
, 'idle');
337 }, "paused -> cancel()");
340 var player
= pausedPlayer();
342 assert_unresolved(player
.startTime
);
343 assert_equals(player
.currentTime
, 100000);
344 assert_equals(player
.playState
, 'paused');
345 }, "paused -> finish()");
348 var player
= pausedPlayer();
350 assert_unresolved(player
.startTime
);
351 assert_equals(player
.currentTime
, 100000);
352 assert_equals(player
.playState
, 'pending');
353 }, "paused -> reverse()");
356 var player
= pausedPlayer();
357 player
.currentTime
= 1000;
358 assert_unresolved(player
.startTime
);
359 assert_equals(player
.currentTime
, 1000);
360 assert_equals(player
.playState
, 'paused');
361 }, "paused -> set currentTime");
364 var player
= pausedPlayer();
365 player
.startTime
= 1000;
366 assert_unresolved(player
.startTime
);
367 assert_equals(player
.currentTime
, 0);
368 assert_equals(player
.playState
, 'paused');
369 }, "paused -> set startTime");
372 var player
= finishedPlayer();
374 assert_unresolved(player
.startTime
);
375 assert_equals(player
.currentTime
, 0);
376 assert_equals(player
.playState
, 'pending');
377 }, "finished -> play()");
380 var player
= finishedPlayer();
382 assert_unresolved(player
.startTime
);
383 assert_equals(player
.currentTime
, 100000);
384 assert_equals(player
.playState
, 'paused');
385 }, "finished -> pause()");
388 var player
= finishedPlayer();
390 assert_unresolved(player
.startTime
);
391 assert_unresolved(player
.currentTime
);
392 assert_equals(player
.playState
, 'idle');
393 }, "finished -> cancel()");
396 var player
= finishedPlayer();
398 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
399 assert_equals(player
.currentTime
, 100000);
400 assert_equals(player
.playState
, 'finished');
401 }, "finished -> finish()");
404 var player
= finishedPlayer();
406 assert_unresolved(player
.startTime
);
407 assert_equals(player
.currentTime
, 100000);
408 assert_equals(player
.playState
, 'pending');
409 }, "finished -> reverse()");
412 var player
= finishedPlayer();
413 player
.currentTime
= 1000;
414 assert_equals(player
.startTime
, document
.timeline
.currentTime
- player
.currentTime
);
415 assert_equals(player
.currentTime
, 1000);
416 assert_equals(player
.playState
, 'running');
417 }, "finished -> set currentTime");