| OLD | NEW |
| (Empty) |
| 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"> | |
| 5 <script src="../../resources/testharness.js"></script> | |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <div id='container'> | |
| 8 <div id='element'></div> | |
| 9 </div> | |
| 10 | |
| 11 <script> | |
| 12 | |
| 13 var container = document.getElementById('container'); | |
| 14 var element = document.getElementById('element'); | |
| 15 | |
| 16 test(function() { | |
| 17 assert_equals(document.getAnimations().length, 0); | |
| 18 assert_equals(container.getAnimations().length, 0); | |
| 19 assert_equals(element.getAnimations().length, 0); | |
| 20 | |
| 21 var animation = element.animate([], 1000); | |
| 22 assert_equals(document.getAnimations().length, 1); | |
| 23 assert_equals(document.getAnimations()[0], animation); | |
| 24 assert_equals(container.getAnimations().length, 0); | |
| 25 assert_equals(element.getAnimations().length, 1); | |
| 26 assert_equals(element.getAnimations()[0], animation); | |
| 27 | |
| 28 var animation2 = container.animate([], 1000); | |
| 29 assert_equals(document.getAnimations().length, 2); | |
| 30 assert_equals(document.getAnimations()[0], animation); | |
| 31 assert_equals(document.getAnimations()[1], animation2); | |
| 32 assert_equals(container.getAnimations().length, 1); | |
| 33 assert_equals(container.getAnimations()[0], animation2); | |
| 34 assert_equals(element.getAnimations().length, 1); | |
| 35 assert_equals(element.getAnimations()[0], animation); | |
| 36 | |
| 37 animation.finish(); | |
| 38 assert_equals(document.getAnimations().length, 1); | |
| 39 assert_equals(document.getAnimations()[0], animation2); | |
| 40 assert_equals(container.getAnimations().length, 1); | |
| 41 assert_equals(container.getAnimations()[0], animation2); | |
| 42 assert_equals(element.getAnimations().length, 0); | |
| 43 | |
| 44 animation2.finish(); | |
| 45 assert_equals(document.getAnimations().length, 0); | |
| 46 assert_equals(container.getAnimations().length, 0); | |
| 47 assert_equals(element.getAnimations().length, 0); | |
| 48 | |
| 49 }, 'getAnimations() normal behaviour (without delays)'); | |
| 50 | |
| 51 test(function() { | |
| 52 assert_equals(document.getAnimations().length, 0); | |
| 53 assert_equals(container.getAnimations().length, 0); | |
| 54 assert_equals(element.getAnimations().length, 0); | |
| 55 | |
| 56 var animation = element.animate([], {duration: 1000, delay: 500}); | |
| 57 assert_equals(document.getAnimations().length, 1); | |
| 58 assert_equals(document.getAnimations()[0], animation); | |
| 59 assert_equals(container.getAnimations().length, 0); | |
| 60 assert_equals(element.getAnimations().length, 1); | |
| 61 assert_equals(element.getAnimations()[0], animation); | |
| 62 | |
| 63 animation.finish(); | |
| 64 assert_equals(document.getAnimations().length, 0); | |
| 65 assert_equals(container.getAnimations().length, 0); | |
| 66 assert_equals(element.getAnimations().length, 0); | |
| 67 | |
| 68 }, 'getAnimations() with animation delays'); | |
| 69 | |
| 70 test(function() { | |
| 71 assert_equals(document.getAnimations().length, 0); | |
| 72 assert_equals(container.getAnimations().length, 0); | |
| 73 assert_equals(element.getAnimations().length, 0); | |
| 74 | |
| 75 var animation = element.animate([], {duration: 1000, delay: 500, fill: 'both
'}); | |
| 76 assert_equals(document.getAnimations().length, 1); | |
| 77 assert_equals(document.getAnimations()[0], animation); | |
| 78 assert_equals(container.getAnimations().length, 0); | |
| 79 assert_equals(element.getAnimations().length, 1); | |
| 80 assert_equals(element.getAnimations()[0], animation); | |
| 81 | |
| 82 animation.finish(); | |
| 83 assert_equals(document.getAnimations().length, 1); | |
| 84 assert_equals(container.getAnimations().length, 0); | |
| 85 assert_equals(element.getAnimations().length, 1); | |
| 86 | |
| 87 }, 'getAnimations() with in effect animations'); | |
| 88 | |
| 89 | |
| 90 </script> | |
| OLD | NEW |