| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Get Animations</title> |
| 4 <link rel="help" href="https://w3c.github.io/web-animations/#dom-document-getan
imations"> |
| 2 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 4 <div id='container'> | 7 <div id='container'> |
| 5 <div id='element'></div> | 8 <div id='element'></div> |
| 6 </div> | 9 </div> |
| 7 | 10 |
| 8 <script> | 11 <script> |
| 9 | 12 |
| 10 var container = document.getElementById('container'); | 13 var container = document.getElementById('container'); |
| 11 var element = document.getElementById('element'); | 14 var element = document.getElementById('element'); |
| 12 | 15 |
| 13 test(function() { | 16 test(function() { |
| 14 assert_equals(document.timeline.getAnimations().length, 0); | 17 assert_equals(document.getAnimations().length, 0); |
| 15 assert_equals(container.getAnimations().length, 0); | 18 assert_equals(container.getAnimations().length, 0); |
| 16 assert_equals(element.getAnimations().length, 0); | 19 assert_equals(element.getAnimations().length, 0); |
| 17 | 20 |
| 18 var animation = element.animate([], 1000); | 21 var animation = element.animate([], 1000); |
| 19 assert_equals(document.timeline.getAnimations().length, 1); | 22 assert_equals(document.getAnimations().length, 1); |
| 20 assert_equals(document.timeline.getAnimations()[0], animation); | 23 assert_equals(document.getAnimations()[0], animation); |
| 21 | |
| 22 var animation2 = container.animate([], 1000); | |
| 23 assert_equals(document.timeline.getAnimations().length, 2); | |
| 24 assert_equals(document.timeline.getAnimations()[0], animation); | |
| 25 assert_equals(document.timeline.getAnimations()[1], animation2); | |
| 26 | |
| 27 animation.finish(); | |
| 28 assert_equals(document.timeline.getAnimations().length, 1); | |
| 29 assert_equals(document.timeline.getAnimations()[0], animation2); | |
| 30 | |
| 31 animation2.finish(); | |
| 32 assert_equals(document.timeline.getAnimations().length, 0); | |
| 33 }, 'Timeline getAnimations()'); | |
| 34 | |
| 35 test(function() { | |
| 36 assert_equals(document.timeline.getAnimations().length, 0); | |
| 37 assert_equals(container.getAnimations().length, 0); | |
| 38 assert_equals(element.getAnimations().length, 0); | |
| 39 | |
| 40 var animation = element.animate([], 1000); | |
| 41 assert_equals(document.timeline.getAnimations().length, 1); | |
| 42 assert_equals(document.timeline.getAnimations()[0], animation); | |
| 43 assert_equals(container.getAnimations().length, 0); | 24 assert_equals(container.getAnimations().length, 0); |
| 44 assert_equals(element.getAnimations().length, 1); | 25 assert_equals(element.getAnimations().length, 1); |
| 45 assert_equals(element.getAnimations()[0], animation); | 26 assert_equals(element.getAnimations()[0], animation); |
| 46 | 27 |
| 47 var animation2 = container.animate([], 1000); | 28 var animation2 = container.animate([], 1000); |
| 48 assert_equals(document.timeline.getAnimations().length, 2); | 29 assert_equals(document.getAnimations().length, 2); |
| 49 assert_equals(document.timeline.getAnimations()[0], animation); | 30 assert_equals(document.getAnimations()[0], animation); |
| 50 assert_equals(document.timeline.getAnimations()[1], animation2); | 31 assert_equals(document.getAnimations()[1], animation2); |
| 51 assert_equals(container.getAnimations().length, 1); | 32 assert_equals(container.getAnimations().length, 1); |
| 52 assert_equals(container.getAnimations()[0], animation2); | 33 assert_equals(container.getAnimations()[0], animation2); |
| 53 assert_equals(element.getAnimations().length, 1); | 34 assert_equals(element.getAnimations().length, 1); |
| 54 assert_equals(element.getAnimations()[0], animation); | 35 assert_equals(element.getAnimations()[0], animation); |
| 55 | 36 |
| 56 animation.finish(); | 37 animation.finish(); |
| 57 assert_equals(document.timeline.getAnimations().length, 1); | 38 assert_equals(document.getAnimations().length, 1); |
| 58 assert_equals(document.timeline.getAnimations()[0], animation2); | 39 assert_equals(document.getAnimations()[0], animation2); |
| 59 assert_equals(container.getAnimations().length, 1); | 40 assert_equals(container.getAnimations().length, 1); |
| 60 assert_equals(container.getAnimations()[0], animation2); | 41 assert_equals(container.getAnimations()[0], animation2); |
| 61 assert_equals(element.getAnimations().length, 0); | 42 assert_equals(element.getAnimations().length, 0); |
| 62 | 43 |
| 63 animation2.finish(); | 44 animation2.finish(); |
| 64 assert_equals(document.timeline.getAnimations().length, 0); | 45 assert_equals(document.getAnimations().length, 0); |
| 65 assert_equals(container.getAnimations().length, 0); | 46 assert_equals(container.getAnimations().length, 0); |
| 66 assert_equals(element.getAnimations().length, 0); | 47 assert_equals(element.getAnimations().length, 0); |
| 67 | 48 |
| 68 }, 'Animatable getAnimations()'); | 49 }, 'getAnimations() normal behaviour (without delays)'); |
| 69 | 50 |
| 70 test(function() { | 51 test(function() { |
| 71 assert_equals(document.timeline.getAnimations().length, 0); | 52 assert_equals(document.getAnimations().length, 0); |
| 72 assert_equals(container.getAnimations().length, 0); | 53 assert_equals(container.getAnimations().length, 0); |
| 73 assert_equals(element.getAnimations().length, 0); | 54 assert_equals(element.getAnimations().length, 0); |
| 74 | 55 |
| 75 var animation = element.animate([], {duration: 1000, delay: 500}); | 56 var animation = element.animate([], {duration: 1000, delay: 500}); |
| 76 assert_equals(document.timeline.getAnimations().length, 1); | 57 assert_equals(document.getAnimations().length, 1); |
| 77 assert_equals(document.timeline.getAnimations()[0], animation); | 58 assert_equals(document.getAnimations()[0], animation); |
| 78 assert_equals(container.getAnimations().length, 0); | 59 assert_equals(container.getAnimations().length, 0); |
| 79 assert_equals(element.getAnimations().length, 1); | 60 assert_equals(element.getAnimations().length, 1); |
| 80 assert_equals(element.getAnimations()[0], animation); | 61 assert_equals(element.getAnimations()[0], animation); |
| 81 | 62 |
| 82 animation.finish(); | 63 animation.finish(); |
| 83 assert_equals(document.timeline.getAnimations().length, 0); | 64 assert_equals(document.getAnimations().length, 0); |
| 84 assert_equals(container.getAnimations().length, 0); | 65 assert_equals(container.getAnimations().length, 0); |
| 85 assert_equals(element.getAnimations().length, 0); | 66 assert_equals(element.getAnimations().length, 0); |
| 86 | 67 |
| 87 }, 'getAnimations() with delays'); | 68 }, 'getAnimations() with animation delays'); |
| 88 | 69 |
| 89 test(function() { | 70 test(function() { |
| 90 assert_equals(document.timeline.getAnimations().length, 0); | 71 assert_equals(document.getAnimations().length, 0); |
| 91 assert_equals(container.getAnimations().length, 0); | 72 assert_equals(container.getAnimations().length, 0); |
| 92 assert_equals(element.getAnimations().length, 0); | 73 assert_equals(element.getAnimations().length, 0); |
| 93 | 74 |
| 94 var animation = element.animate([], {duration: 1000, delay: 500, fill: 'both
'}); | 75 var animation = element.animate([], {duration: 1000, delay: 500, fill: 'both
'}); |
| 95 assert_equals(document.timeline.getAnimations().length, 1); | 76 assert_equals(document.getAnimations().length, 1); |
| 96 assert_equals(document.timeline.getAnimations()[0], animation); | 77 assert_equals(document.getAnimations()[0], animation); |
| 97 assert_equals(container.getAnimations().length, 0); | 78 assert_equals(container.getAnimations().length, 0); |
| 98 assert_equals(element.getAnimations().length, 1); | 79 assert_equals(element.getAnimations().length, 1); |
| 99 assert_equals(element.getAnimations()[0], animation); | 80 assert_equals(element.getAnimations()[0], animation); |
| 100 | 81 |
| 101 animation.finish(); | 82 animation.finish(); |
| 102 assert_equals(document.timeline.getAnimations().length, 1); | 83 assert_equals(document.getAnimations().length, 1); |
| 103 // assert_equals(container.getAnimations().length, 1); | 84 assert_equals(container.getAnimations().length, 0); |
| 104 // assert_equals(element.getAnimations().length, 1); | 85 assert_equals(element.getAnimations().length, 1); |
| 105 | 86 |
| 106 }, 'getAnimations() - in effect animations'); | 87 }, 'getAnimations() with in effect animations'); |
| 88 |
| 107 | 89 |
| 108 </script> | 90 </script> |
| OLD | NEW |