| 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 <body> |
| 6 <div id='element'></div> |
| 7 </body> |
| 8 |
| 5 <script> | 9 <script> |
| 10 var element = document.getElementById('element'); |
| 11 var duration = 1; |
| 12 |
| 13 var animation = new Animation(element, |
| 14 [{opacity: '1', offset: 0}, |
| 15 {opacity: '0', offset: 1}], |
| 16 duration); |
| 17 |
| 6 test(function() { | 18 test(function() { |
| 7 var startTime = document.timeline.currentTime; | 19 var startTime = document.timeline.currentTime; |
| 8 assert_greater_than_equal(startTime, 0); | 20 var player = document.timeline.play(animation); |
| 9 var start = performance.now(); | 21 player.finish(); |
| 10 while (performance.now() < start + 250) | 22 var finishTime = document.timeline.currentTime; |
| 11 /* wait */; | 23 assert_greater_than_equal(startTime, 0); |
| 12 assert_equals(document.timeline.currentTime, startTime); | 24 assert_equals(startTime, finishTime); |
| 13 }, 'document.timeline.currentTime should not change within a script block.'); | 25 }, 'document.timeline.currentTime should not change within a script block.'); |
| 14 | |
| 15 (function() { | |
| 16 var timeoutTest = async_test('document.timeline.currentTime time should change
after a script timeout'); | |
| 17 var startTime = document.timeline.currentTime; | |
| 18 | |
| 19 setTimeout(function() { | |
| 20 timeoutTest.step(function() { | |
| 21 assert_greater_than(document.timeline.currentTime, startTime); | |
| 22 }); | |
| 23 timeoutTest.done(); | |
| 24 }, 100); | |
| 25 })(); | |
| 26 | |
| 27 (function() { | |
| 28 var rafTest = async_test('document.timeline.currentTime time should be the sam
e for all RAF callbacks in a frame'); | |
| 29 var startTime = document.timeline.currentTime; | |
| 30 var firstRafTime; | |
| 31 | |
| 32 requestAnimationFrame(function() { | |
| 33 rafTest.step(function() { | |
| 34 assert_greater_than_equal(document.timeline.currentTime, startTime); | |
| 35 firstRafTime = document.timeline.currentTime; | |
| 36 }); | |
| 37 }); | |
| 38 | |
| 39 requestAnimationFrame(function() { | |
| 40 rafTest.step(function() { | |
| 41 assert_equals(document.timeline.currentTime, firstRafTime); | |
| 42 }); | |
| 43 rafTest.done(); | |
| 44 }); | |
| 45 })(); | |
| 46 </script> | 26 </script> |
| OLD | NEW |