Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 | 4 |
| 5 <script> | 5 <script> |
| 6 var duration = 100000; | 6 var duration = 100000; |
| 7 | 7 |
| 8 function assert_unresolved(value) { | 8 function assert_unresolved(value) { |
| 9 assert_equals(value, null); | 9 assert_equals(value, null); |
| 10 } | 10 } |
| 11 | 11 |
| 12 function idleAnimation() { | 12 function idleAnimation() { |
| 13 var animation = document.documentElement.animate([], duration); | 13 var animation = document.documentElement.animate([], duration); |
| 14 animation.reverse(); | 14 animation.reverse(); |
| 15 animation.cancel(); | 15 animation.cancel(); |
| 16 return animation; | 16 return animation; |
| 17 } | 17 } |
| 18 | 18 |
| 19 function runningAnimation() { | 19 function runningAnimation() { |
| 20 var animation = idleAnimation(); | 20 var animation = idleAnimation(); |
| 21 animation.play(); | 21 animation.play(); |
| 22 animation.startTime = document.timeline.currentTime + duration; | 22 animation.startTime = document.timeline.currentTime + duration/2; |
|
dstockwell
2016/03/31 03:10:13
Nit. spaces around binary operators.
| |
| 23 return animation; | 23 return animation; |
| 24 } | 24 } |
| 25 | 25 |
| 26 function pendingStartTimeAnimation() { | 26 function pendingStartTimeAnimation() { |
| 27 var animation = idleAnimation(); | 27 var animation = idleAnimation(); |
| 28 animation.play(); | 28 animation.play(); |
| 29 return animation; | 29 return animation; |
| 30 } | 30 } |
| 31 | 31 |
| 32 function pausedAnimation() { | 32 function pausedAnimation() { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 53 test(function() { | 53 test(function() { |
| 54 var animation = pendingStartTimeAnimation(); | 54 var animation = pendingStartTimeAnimation(); |
| 55 assert_unresolved(animation.startTime); | 55 assert_unresolved(animation.startTime); |
| 56 assert_equals(animation.currentTime, duration); | 56 assert_equals(animation.currentTime, duration); |
| 57 assert_equals(animation.playState, 'pending'); | 57 assert_equals(animation.playState, 'pending'); |
| 58 }, "pending startTime"); | 58 }, "pending startTime"); |
| 59 | 59 |
| 60 test(function() { | 60 test(function() { |
| 61 var animation = runningAnimation(); | 61 var animation = runningAnimation(); |
| 62 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); | 62 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); |
| 63 assert_equals(animation.currentTime, duration); | 63 assert_equals(animation.currentTime, duration/2); |
| 64 assert_equals(animation.playState, 'running'); | 64 assert_equals(animation.playState, 'running'); |
| 65 }, "running"); | 65 }, "running"); |
| 66 | 66 |
| 67 test(function() { | 67 test(function() { |
| 68 var animation = pausedAnimation(); | 68 var animation = pausedAnimation(); |
| 69 assert_unresolved(animation.startTime); | 69 assert_unresolved(animation.startTime); |
| 70 assert_equals(animation.currentTime, duration); | 70 assert_equals(animation.currentTime, duration); |
| 71 assert_equals(animation.playState, 'paused'); | 71 assert_equals(animation.playState, 'paused'); |
| 72 }, "paused"); | 72 }, "paused"); |
| 73 | 73 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 animation.play(); | 197 animation.play(); |
| 198 assert_equals(animation.startTime, startTime); | 198 assert_equals(animation.startTime, startTime); |
| 199 assert_equals(animation.currentTime, currentTime); | 199 assert_equals(animation.currentTime, currentTime); |
| 200 assert_equals(animation.playState, 'running'); | 200 assert_equals(animation.playState, 'running'); |
| 201 }, "running -> play()"); | 201 }, "running -> play()"); |
| 202 | 202 |
| 203 test(function() { | 203 test(function() { |
| 204 var animation = runningAnimation(); | 204 var animation = runningAnimation(); |
| 205 animation.pause(); | 205 animation.pause(); |
| 206 assert_unresolved(animation.startTime); | 206 assert_unresolved(animation.startTime); |
| 207 assert_equals(animation.currentTime, duration); | 207 assert_equals(animation.currentTime, duration/2); |
| 208 assert_equals(animation.playState, 'pending'); | 208 assert_equals(animation.playState, 'pending'); |
| 209 }, "running -> pause()"); | 209 }, "running -> pause()"); |
| 210 | 210 |
| 211 test(function() { | 211 test(function() { |
| 212 var animation = runningAnimation(); | 212 var animation = runningAnimation(); |
| 213 animation.cancel(); | 213 animation.cancel(); |
| 214 assert_unresolved(animation.startTime); | 214 assert_unresolved(animation.startTime); |
| 215 assert_unresolved(animation.currentTime); | 215 assert_unresolved(animation.currentTime); |
| 216 assert_equals(animation.playState, 'idle'); | 216 assert_equals(animation.playState, 'idle'); |
| 217 }, "running -> cancel()"); | 217 }, "running -> cancel()"); |
| 218 | 218 |
| 219 test(function() { | 219 test(function() { |
| 220 var animation = runningAnimation(); | 220 var animation = runningAnimation(); |
| 221 animation.finish(); | 221 animation.finish(); |
| 222 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); | 222 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); |
| 223 assert_equals(animation.currentTime, 0); | 223 assert_equals(animation.currentTime, 0); |
| 224 assert_equals(animation.playState, 'finished'); | 224 assert_equals(animation.playState, 'finished'); |
| 225 }, "running -> finish()"); | 225 }, "running -> finish()"); |
| 226 | 226 |
| 227 test(function() { | 227 test(function() { |
| 228 var animation = runningAnimation(); | 228 var animation = runningAnimation(); |
| 229 animation.reverse(); | 229 animation.reverse(); |
| 230 assert_unresolved(animation.startTime); | 230 assert_unresolved(animation.startTime); |
| 231 assert_equals(animation.currentTime, 0); | 231 assert_equals(animation.currentTime, duration/2); |
| 232 assert_equals(animation.playState, 'pending'); | 232 assert_equals(animation.playState, 'pending'); |
| 233 }, "running -> reverse()"); | 233 }, "running -> reverse()"); |
| 234 | 234 |
| 235 test(function() { | 235 test(function() { |
| 236 var animation = runningAnimation(); | 236 var animation = runningAnimation(); |
| 237 animation.currentTime = 1000; | 237 animation.currentTime = 1000; |
| 238 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); | 238 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); |
| 239 assert_equals(animation.currentTime, 1000); | 239 assert_equals(animation.currentTime, 1000); |
| 240 assert_equals(animation.playState, 'running'); | 240 assert_equals(animation.playState, 'running'); |
| 241 }, "running -> set currentTime"); | 241 }, "running -> set currentTime"); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 345 }, "finished -> reverse()"); | 345 }, "finished -> reverse()"); |
| 346 | 346 |
| 347 test(function() { | 347 test(function() { |
| 348 var animation = finishedAnimation(); | 348 var animation = finishedAnimation(); |
| 349 animation.currentTime = 1000; | 349 animation.currentTime = 1000; |
| 350 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); | 350 assert_equals(animation.startTime, document.timeline.currentTime - (animation. playbackRate * animation.currentTime)); |
| 351 assert_equals(animation.currentTime, 1000); | 351 assert_equals(animation.currentTime, 1000); |
| 352 assert_equals(animation.playState, 'running'); | 352 assert_equals(animation.playState, 'running'); |
| 353 }, "finished -> set currentTime"); | 353 }, "finished -> set currentTime"); |
| 354 </script> | 354 </script> |
| OLD | NEW |