OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Tests for updating the finished state of an animation</title> | 3 <title>Tests for updating the finished state of an animation</title> |
4 <link rel="help" href="https://w3c.github.io/web-animations/#updating-the-finish
ed-state"> | 4 <link rel="help" href="https://w3c.github.io/web-animations/#updating-the-finish
ed-state"> |
5 <script src="/resources/testharness.js"></script> | 5 <script src="/resources/testharness.js"></script> |
6 <script src="/resources/testharnessreport.js"></script> | 6 <script src="/resources/testharnessreport.js"></script> |
7 <script src="../../testcommon.js"></script> | 7 <script src="../../testcommon.js"></script> |
8 <body> | 8 <body> |
9 <div id="log"></div> | 9 <div id="log"></div> |
10 <script> | 10 <script> |
(...skipping 25 matching lines...) Expand all Loading... |
36 // (Also the start time is resolved and there is pending task) | 36 // (Also the start time is resolved and there is pending task) |
37 | 37 |
38 // Did seek = false | 38 // Did seek = false |
39 promise_test(function(t) { | 39 promise_test(function(t) { |
40 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); | 40 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); |
41 | 41 |
42 // Here and in the following tests we wait until ready resolves as | 42 // Here and in the following tests we wait until ready resolves as |
43 // otherwise we don't have a resolved start time. We test the case | 43 // otherwise we don't have a resolved start time. We test the case |
44 // where the start time is unresolved in a subsequent test. | 44 // where the start time is unresolved in a subsequent test. |
45 return anim.ready.then(function() { | 45 return anim.ready.then(function() { |
46 // Seek to 1ms before the target end and then wait 1ms | 46 // Seek to 1ms before the target end and wait a frame (> 16ms) |
47 anim.currentTime = 100 * MS_PER_SEC - 1; | 47 anim.currentTime = 100 * MS_PER_SEC - 1; |
48 return waitForAnimationFramesWithDelay(1); | 48 return waitForAnimationFrames(1); |
49 }).then(function() { | 49 }).then(function() { |
50 assert_equals(anim.currentTime, 100 * MS_PER_SEC, | 50 assert_equals(anim.currentTime, 100 * MS_PER_SEC, |
51 'Hold time is set to target end clamping current time'); | 51 'Hold time is set to target end clamping current time'); |
52 }); | 52 }); |
53 }, 'Updating the finished state when playing past end'); | 53 }, 'Updating the finished state when playing past end'); |
54 | 54 |
55 // Did seek = true | 55 // Did seek = true |
56 promise_test(function(t) { | 56 promise_test(function(t) { |
57 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); | 57 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); |
58 return anim.ready.then(function() { | 58 return anim.ready.then(function() { |
(...skipping 30 matching lines...) Expand all Loading... |
89 | 89 |
90 // CASE 2: playback rate < 0 and current time <= 0 | 90 // CASE 2: playback rate < 0 and current time <= 0 |
91 // (Also the start time is resolved and there is pending task) | 91 // (Also the start time is resolved and there is pending task) |
92 | 92 |
93 // Did seek = false | 93 // Did seek = false |
94 promise_test(function(t) { | 94 promise_test(function(t) { |
95 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); | 95 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); |
96 anim.playbackRate = -1; | 96 anim.playbackRate = -1; |
97 anim.play(); // Make sure animation is not initially finished | 97 anim.play(); // Make sure animation is not initially finished |
98 return anim.ready.then(function() { | 98 return anim.ready.then(function() { |
99 // Seek to 1ms before 0 and then wait 1ms | 99 // Seek to 1ms before 0 end and wait a frame (> 16ms) |
100 anim.currentTime = 1; | 100 anim.currentTime = 1; |
101 return waitForAnimationFramesWithDelay(1); | 101 return waitForAnimationFrames(1); |
102 }).then(function() { | 102 }).then(function() { |
103 assert_equals(anim.currentTime, 0 * MS_PER_SEC, | 103 assert_equals(anim.currentTime, 0 * MS_PER_SEC, |
104 'Hold time is set to zero clamping current time'); | 104 'Hold time is set to zero clamping current time'); |
105 }); | 105 }); |
106 }, 'Updating the finished state when playing in reverse past zero'); | 106 }, 'Updating the finished state when playing in reverse past zero'); |
107 | 107 |
108 // Did seek = true | 108 // Did seek = true |
109 promise_test(function(t) { | 109 promise_test(function(t) { |
110 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); | 110 var anim = createDiv(t).animate(null, 100 * MS_PER_SEC); |
111 anim.playbackRate = -1; | 111 anim.playbackRate = -1; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 anim.currentTime = 50 * MS_PER_SEC; | 322 anim.currentTime = 50 * MS_PER_SEC; |
323 assert_equals(anim.currentTime, 50 * MS_PER_SEC, | 323 assert_equals(anim.currentTime, 50 * MS_PER_SEC, |
324 'The animation hold time should not be updated'); | 324 'The animation hold time should not be updated'); |
325 assert_equals(anim.startTime, null, | 325 assert_equals(anim.startTime, null, |
326 'The animation start time should not be updated'); | 326 'The animation start time should not be updated'); |
327 }, 'Updating the finished state when start time is unresolved and' | 327 }, 'Updating the finished state when start time is unresolved and' |
328 + ' did seek = true'); | 328 + ' did seek = true'); |
329 | 329 |
330 </script> | 330 </script> |
331 </body> | 331 </body> |
OLD | NEW |