|
325 | 325 | }, 'Setting the start time on a reverse running animation updates the play '
|
326 | 326 | + 'state');
|
327 | 327 |
|
| 328 | +promise_test(async t => { |
| 329 | + const make_animation = () => createDiv(t).animate(null, 100 * MS_PER_SEC); |
| 330 | + |
| 331 | + // Wait for a couple of page rendering updates to run and record the timeline time. |
| 332 | + await waitForAnimationFrames(2); |
| 333 | + const timelineTimeForFirstPageRenderingUpdate = document.timeline.currentTime; |
| 334 | + |
| 335 | + // Create a first animation that is created during the page rendering update. |
| 336 | + // This animation should have its start time set to the current timeline time. |
| 337 | + const animStartedDuringPageRenderingUpdate = make_animation(); |
| 338 | + |
| 339 | + // Wait for a new JS call frame and start another animation. This animation |
| 340 | + // should have its start time set to the timeline time of the next page |
| 341 | + // rendering update. |
| 342 | + await new Promise(setTimeout); |
| 343 | + const animStartedAfterTimeout = make_animation(); |
| 344 | + |
| 345 | + // Wait for another new JS call frame and start another animation. This |
| 346 | + // animation, like the previous one, should have its start time set to |
| 347 | + // the timeline time of the next page rendering update. |
| 348 | + await new Promise(setTimeout); |
| 349 | + const animStartedAfterAnotherTimeout = make_animation(); |
| 350 | + |
| 351 | + // Now wait until the next page rendering update and record the timeline time. |
| 352 | + await waitForAnimationFrames(1); |
| 353 | + const timelineTimeForSecondPageRenderingUpdate = document.timeline.currentTime; |
| 354 | + |
| 355 | + // Create an animation that is created during this second page rendering update. |
| 356 | + // This animation should have its start time set to the new timeline time. |
| 357 | + const animStartedDuringSecondPageRenderingUpdate = make_animation(); |
| 358 | + |
| 359 | + // All animations should be ready by the next animation frame. |
| 360 | + await waitForAnimationFrames(1); |
| 361 | + |
| 362 | + const assert_start_time = (animation, expected, description) => { |
| 363 | + assert_approx_equals(animation.startTime, expected, 0.0001, |
| 364 | + `Start time of animation started ${description}`); |
| 365 | + }; |
| 366 | + |
| 367 | + assert_start_time(animStartedDuringPageRenderingUpdate, |
| 368 | + timelineTimeForFirstPageRenderingUpdate, |
| 369 | + "during the first page rendering update"); |
| 370 | + assert_start_time(animStartedAfterTimeout, |
| 371 | + timelineTimeForSecondPageRenderingUpdate, |
| 372 | + "after waiting for a new JS call frame"); |
| 373 | + assert_start_time(animStartedAfterAnotherTimeout, |
| 374 | + timelineTimeForSecondPageRenderingUpdate, |
| 375 | + "after waiting for another new JS call frame"); |
| 376 | + assert_start_time(animStartedDuringSecondPageRenderingUpdate, |
| 377 | + timelineTimeForSecondPageRenderingUpdate, |
| 378 | + "during the second page rendering update"); |
| 379 | +}, 'Checking the start time of animations started at various times between two page rendering updates'); |
| 380 | + |
328 | 381 | </script>
|
329 | 382 | </body>
|
0 commit comments