OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Animation.finished</title> | 3 <title>Animation.finished</title> |
4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-finis
hed"> | 4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-finis
hed"> |
5 <script src="/resources/testharness.js"></script> | 5 <script src="/resources/testharness.js"></script> |
6 <script src="/resources/testharnessreport.js"></script> | 6 <script src="/resources/testharnessreport.js"></script> |
7 <script src="../../testcommon.js"></script> | 7 <script src="../../testcommon.js"></script> |
8 <body> | 8 <body> |
9 <div id="log"></div> | 9 <div id="log"></div> |
10 <script> | 10 <script> |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 animation.finished.then(t.step_func(function() { | 359 animation.finished.then(t.step_func(function() { |
360 assert_unreached('Animation.finished should not be resolved'); | 360 assert_unreached('Animation.finished should not be resolved'); |
361 })); | 361 })); |
362 animation.currentTime = 0; | 362 animation.currentTime = 0; |
363 }); | 363 }); |
364 | 364 |
365 }, 'Test finished promise is not resolved once the animation ' + | 365 }, 'Test finished promise is not resolved once the animation ' + |
366 'falls out finished state even though the current finished ' + | 366 'falls out finished state even though the current finished ' + |
367 'promise is generated soon after animation state became finished'); | 367 'promise is generated soon after animation state became finished'); |
368 | 368 |
| 369 promise_test(function(t) { |
| 370 var animation = createDiv(t).animate(null, 100 * MS_PER_SEC); |
| 371 var ready = false; |
| 372 animation.ready.then( |
| 373 t.step_func(function() { |
| 374 ready = true; |
| 375 }), |
| 376 t.unreached_func('Ready promise must not be rejected') |
| 377 ); |
| 378 |
| 379 var testSuccess = animation.finished.then( |
| 380 t.step_func(function() { |
| 381 assert_true(ready, 'Ready promise has resolved'); |
| 382 }), |
| 383 t.unreached_func('Finished promise must not be rejected') |
| 384 ); |
| 385 |
| 386 var timeout = waitForAnimationFrames(3).then(function() { |
| 387 return Promise.reject('Finished promise did not arrive in time'); |
| 388 }); |
| 389 |
| 390 animation.finish(); |
| 391 return Promise.race([timeout, testSuccess]); |
| 392 }, 'Finished promise should be resolved after the ready promise is resolved'); |
| 393 |
| 394 promise_test(function(t) { |
| 395 var animation = createDiv(t).animate(null, 100 * MS_PER_SEC); |
| 396 var caught = false; |
| 397 animation.ready.then( |
| 398 t.unreached_func('Ready promise must not be resolved'), |
| 399 t.step_func(function() { |
| 400 caught = true; |
| 401 }) |
| 402 ); |
| 403 |
| 404 var testSuccess = animation.finished.then( |
| 405 t.unreached_func('Finished promise must not be resolved'), |
| 406 t.step_func(function() { |
| 407 assert_true(caught, 'Ready promise has been rejected'); |
| 408 }) |
| 409 ); |
| 410 |
| 411 var timeout = waitForAnimationFrames(3).then(function() { |
| 412 return Promise.reject('Finished promise was not rejected in time'); |
| 413 }); |
| 414 |
| 415 animation.cancel(); |
| 416 return Promise.race([timeout, testSuccess]); |
| 417 }, 'Finished promise should be rejected after the ready promise is rejected'); |
| 418 |
369 </script> | 419 </script> |
370 </body> | 420 </body> |
OLD | NEW |