| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>Test Animation.ready attribute</title> | |
| 4 <link rel="https://w3c.github.io/web-animations/#the-animation-interface"> | |
| 5 <script src="../resources/testharness.js"></script> | |
| 6 <script src="../resources/testharnessreport.js"></script> | |
| 7 <script src="../external/wpt/web-animations/testcommon.js"></script> | |
| 8 | |
| 9 <script> | |
| 10 test(function() { | |
| 11 var animation = document.documentElement.animate([], 100000); | |
| 12 assert_true(animation.ready instanceof Promise); | |
| 13 }, 'The ready attribute should be a Promise'); | |
| 14 | |
| 15 async_test(function(t) { | |
| 16 var animation = document.documentElement.animate([], 100000); | |
| 17 animation.cancel(); | |
| 18 animation.ready.then(function(p) { | |
| 19 t.step(function() { | |
| 20 assert_equals(p, animation); | |
| 21 }); | |
| 22 t.done(); | |
| 23 }); | |
| 24 }, 'The ready promise should be resolved when an animation is in the idle play s
tate'); | |
| 25 | |
| 26 test(function() { | |
| 27 var animation = document.documentElement.animate([], 100000); | |
| 28 var promise = animation.ready; | |
| 29 animation.cancel(); | |
| 30 assert_not_equals(animation.ready, promise); | |
| 31 }, 'The ready promise should be replaced when the animation is cancelled'); | |
| 32 | |
| 33 test(function() { | |
| 34 var animation = document.documentElement.animate([], 100000); | |
| 35 animation.cancel(); | |
| 36 var promise = animation.ready; | |
| 37 animation.play(); | |
| 38 assert_not_equals(animation.ready, promise); | |
| 39 }, 'The ready promise should be replaced when the animation enters the pending s
tate'); | |
| 40 | |
| 41 async_test(function(t) { | |
| 42 var animation = document.documentElement.animate([], 100000); | |
| 43 animation.ready.then(function() { | |
| 44 t.step(function() { | |
| 45 assert_unreached(); | |
| 46 }); | |
| 47 }, function(e) { | |
| 48 t.step(function() { | |
| 49 assert_equals(e.code, DOMException.ABORT_ERR); | |
| 50 }); | |
| 51 t.done(); | |
| 52 }); | |
| 53 animation.cancel(); | |
| 54 }, 'A pending ready promise should be rejected when the animation is cancelled')
; | |
| 55 | |
| 56 async_test(function(t) { | |
| 57 var animation = document.documentElement.animate([], 100000); | |
| 58 var promise = animation.ready; | |
| 59 promise.then(function(p) { | |
| 60 t.step(function() { | |
| 61 assert_equals(p, animation); | |
| 62 assert_equals(animation.ready, promise); | |
| 63 }); | |
| 64 t.done(); | |
| 65 }); | |
| 66 }, 'A pending ready promise should be resolved and not replaced when the animati
on enters the running state'); | |
| 67 | |
| 68 async_test(function(t) { | |
| 69 var animation = document.documentElement.animate([], 100000); | |
| 70 var promise = animation.ready; | |
| 71 animation.finish(); | |
| 72 promise.then(function(p) { | |
| 73 t.step(function() { | |
| 74 assert_equals(p, animation); | |
| 75 assert_equals(animation.ready, promise); | |
| 76 }); | |
| 77 t.done(); | |
| 78 }); | |
| 79 }, 'A pending ready promise should be resolved and not replaced when the animati
on enters the finished state'); | |
| 80 | |
| 81 async_test(function(t) { | |
| 82 var animation = document.documentElement.animate([], 100000); | |
| 83 var promise = animation.ready; | |
| 84 animation.pause(); | |
| 85 promise.then(function(p) { | |
| 86 t.step(function() { | |
| 87 assert_equals(p, animation); | |
| 88 assert_equals(animation.ready, promise); | |
| 89 }); | |
| 90 t.done(); | |
| 91 }); | |
| 92 }, 'A pending ready promise should be resolved and not replaced when the animati
on enters the paused state'); | |
| 93 </script> | |
| OLD | NEW |