OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Tests for current time</title> |
| 4 <link rel="help" href="https://w3c.github.io/web-animations/#current-time"> |
| 5 <script src="/resources/testharness.js"></script> |
| 6 <script src="/resources/testharnessreport.js"></script> |
| 7 <script src="../../testcommon.js"></script> |
| 8 <body> |
| 9 <div id="log"></div> |
| 10 <script> |
| 11 'use strict'; |
| 12 |
| 13 test(function(t) { |
| 14 var animation = |
| 15 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC), |
| 16 document.timeline); |
| 17 |
| 18 animation.play(); |
| 19 assert_equals(animation.currentTime, 0, |
| 20 'Current time returns the hold time set when entering the play-pending ' + |
| 21 'state'); |
| 22 }, 'The current time returns the hold time when set'); |
| 23 |
| 24 promise_test(function(t) { |
| 25 var animation = |
| 26 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC), |
| 27 null); |
| 28 |
| 29 return animation.ready.then(function() { |
| 30 assert_equals(animation.currentTime, null); |
| 31 }); |
| 32 }, 'The current time is unresolved when there is no associated timeline ' + |
| 33 '(and no hold time is set)'); |
| 34 |
| 35 // FIXME: Test that the current time is unresolved when we have an inactive |
| 36 // timeline if we find a way of creating an inactive timeline! |
| 37 |
| 38 test(function(t) { |
| 39 var animation = |
| 40 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC), |
| 41 document.timeline); |
| 42 |
| 43 animation.startTime = null; |
| 44 assert_equals(animation.currentTime, null); |
| 45 }, 'The current time is unresolved when the start time is unresolved ' + |
| 46 '(and no hold time is set)'); |
| 47 |
| 48 promise_test(function(t) { |
| 49 var animation = |
| 50 new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC), |
| 51 document.timeline); |
| 52 |
| 53 animation.playbackRate = 2; |
| 54 animation.startTime = document.timeline.currentTime - 25 * MS_PER_SEC; |
| 55 |
| 56 var timelineTime = document.timeline.currentTime; |
| 57 var startTime = animation.startTime; |
| 58 var playbackRate = animation.playbackRate; |
| 59 assert_times_equal(animation.currentTime, |
| 60 (timelineTime - startTime) * playbackRate, |
| 61 'Animation has a unresolved start time'); |
| 62 }, 'The current time is calculated from the timeline time, start time and ' + |
| 63 'playback rate'); |
| 64 </script> |
| 65 </body> |
OLD | NEW |