OLD | NEW |
(Empty) | |
| 1 <script src="../resources/testharness.js"></script> |
| 2 <script src="../resources/testharnessreport.js"></script> |
| 3 <style> |
| 4 @keyframes a {} |
| 5 @keyframes b {} |
| 6 </style> |
| 7 <div id="target"></div> |
| 8 <script> |
| 9 function setAnimationProperty(value) { |
| 10 target.style.animation = value; |
| 11 target.offsetTop; |
| 12 } |
| 13 |
| 14 function getAnimations() { |
| 15 return document.timeline.getAnimations(); |
| 16 } |
| 17 |
| 18 function clearAnimations() { |
| 19 setAnimationProperty('none'); |
| 20 assert_equals(getAnimations().length, 0); |
| 21 } |
| 22 |
| 23 test(() => { |
| 24 clearAnimations(); |
| 25 setAnimationProperty('a 1000ms 1500ms forwards, a 2000ms 2500ms backwards, a 3
000ms 3500ms both'); |
| 26 var animations = getAnimations(); |
| 27 assert_equals(animations.length, 3); |
| 28 assert_equals(animations[0].effect.timing.duration, 1000); |
| 29 assert_equals(animations[0].effect.timing.delay, 1500); |
| 30 assert_equals(animations[0].effect.timing.fill, 'forwards'); |
| 31 |
| 32 assert_equals(animations[1].effect.timing.duration, 2000); |
| 33 assert_equals(animations[1].effect.timing.delay, 2500); |
| 34 assert_equals(animations[1].effect.timing.fill, 'backwards'); |
| 35 |
| 36 assert_equals(animations[2].effect.timing.duration, 3000); |
| 37 assert_equals(animations[2].effect.timing.delay, 3500); |
| 38 assert_equals(animations[2].effect.timing.fill, 'both'); |
| 39 }, 'Multiple same animation names should start multiple animations.'); |
| 40 |
| 41 test(() => { |
| 42 clearAnimations(); |
| 43 |
| 44 setAnimationProperty('a 1500ms paused, a 2500ms paused, a 3500ms paused'); |
| 45 var animations = getAnimations(); |
| 46 assert_equals(animations.length, 3); |
| 47 animations[0].currentTime = 1000; |
| 48 animations[1].currentTime = 2000; |
| 49 animations[2].currentTime = 3000; |
| 50 |
| 51 setAnimationProperty('a 1750ms paused, a 2750ms paused, a 3750ms paused'); |
| 52 animations = getAnimations(); |
| 53 assert_equals(animations.length, 3); |
| 54 |
| 55 assert_equals(animations[0].currentTime, 1000); |
| 56 assert_equals(animations[0].effect.timing.duration, 1750); |
| 57 |
| 58 assert_equals(animations[1].currentTime, 2000); |
| 59 assert_equals(animations[1].effect.timing.duration, 2750); |
| 60 |
| 61 assert_equals(animations[2].currentTime, 3000); |
| 62 assert_equals(animations[2].effect.timing.duration, 3750); |
| 63 }, 'Multiple same animation names should persist with animation timing updates.'
); |
| 64 |
| 65 test(() => { |
| 66 clearAnimations(); |
| 67 |
| 68 setAnimationProperty('a 1500ms paused, a 2500ms paused, b 3500ms paused, b 450
0ms paused'); |
| 69 var animations = getAnimations(); |
| 70 assert_equals(animations.length, 4); |
| 71 animations[0].currentTime = 1000; |
| 72 animations[1].currentTime = 2000; |
| 73 animations[2].currentTime = 3000; |
| 74 animations[3].currentTime = 4000; |
| 75 |
| 76 setAnimationProperty('a 1500ms paused, b 3500ms paused, a 2500ms paused, b 450
0ms paused'); |
| 77 animations = getAnimations(); |
| 78 assert_equals(animations.length, 4); |
| 79 |
| 80 assert_equals(animations[0].currentTime, 1000); |
| 81 assert_equals(animations[0].effect.timing.duration, 1500); |
| 82 |
| 83 assert_equals(animations[1].currentTime, 2000); |
| 84 assert_equals(animations[1].effect.timing.duration, 2500); |
| 85 |
| 86 assert_equals(animations[2].currentTime, 3000); |
| 87 assert_equals(animations[2].effect.timing.duration, 3500); |
| 88 |
| 89 assert_equals(animations[3].currentTime, 4000); |
| 90 assert_equals(animations[3].effect.timing.duration, 4500); |
| 91 }, 'Mixed multiple same animation names should persist based on their same name
relative position'); |
| 92 |
| 93 test(() => { |
| 94 clearAnimations(); |
| 95 |
| 96 setAnimationProperty('a 1500ms paused, a 2500ms paused, a 3500ms paused'); |
| 97 var animations = getAnimations(); |
| 98 assert_equals(animations.length, 3); |
| 99 animations[0].currentTime = 1000; |
| 100 animations[1].currentTime = 2000; |
| 101 animations[2].currentTime = 3000; |
| 102 |
| 103 setAnimationProperty('a 1500ms paused, b 2500ms paused, a 3500ms paused'); |
| 104 animations = getAnimations(); |
| 105 assert_equals(animations.length, 3); |
| 106 |
| 107 assert_equals(animations[0].currentTime, 1000); |
| 108 assert_equals(animations[0].effect.timing.duration, 1500); |
| 109 |
| 110 assert_equals(animations[1].currentTime, 2000); |
| 111 assert_equals(animations[1].effect.timing.duration, 3500); |
| 112 |
| 113 assert_equals(animations[2].currentTime, null); |
| 114 assert_equals(animations[2].effect.timing.duration, 2500); |
| 115 }, 'Removing same animation names should cancel animations from the end of the n
ame list.'); |
| 116 |
| 117 test(() => { |
| 118 clearAnimations(); |
| 119 |
| 120 setAnimationProperty('a 1500ms paused, a 2500ms paused'); |
| 121 var animations = getAnimations(); |
| 122 assert_equals(animations.length, 2); |
| 123 animations[0].currentTime = 1000; |
| 124 animations[1].currentTime = 2000; |
| 125 |
| 126 setAnimationProperty('a 3500ms paused, a 2500ms paused, a 1500ms paused'); |
| 127 animations = getAnimations(); |
| 128 assert_equals(animations.length, 3); |
| 129 |
| 130 assert_equals(animations[0].currentTime, 1000); |
| 131 assert_equals(animations[0].effect.timing.duration, 3500); |
| 132 |
| 133 assert_equals(animations[1].currentTime, 2000); |
| 134 assert_equals(animations[1].effect.timing.duration, 2500); |
| 135 |
| 136 assert_equals(animations[2].currentTime, null); |
| 137 assert_equals(animations[2].effect.timing.duration, 1500); |
| 138 }, 'Adding same animation names should start additional animations from the end
of the name list.'); |
| 139 </script> |
OLD | NEW |