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