| <!DOCTYPE html> |
| <html> |
| <title>Test repeatedly chaining video.rAF() callbacks.</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/common/media.js"></script> |
| <script> |
| |
| async_test(function(t) { |
| let video = document.createElement('video'); |
| |
| let firstTime; |
| video.requestAnimationFrame(t.step_func((time) => { |
| firstTime = time; |
| |
| // Queue up a callback and make sure it's not immediately executed. |
| let secondTime; |
| video.requestAnimationFrame(t.step_func((time) => { |
| secondTime = time; |
| assert_greater_than(secondTime, firstTime, "Callbacks should be executed on the next frame"); |
| })) |
| |
| // Queue up a second callback, and make sure it's called at the same time |
| // as the one we just queued up. |
| video.requestAnimationFrame(t.step_func_done((time) => { |
| assert_equals(time, secondTime, "Callbacks queued together should be called at the same time"); |
| })) |
| |
| })); |
| |
| video.src = getVideoURI('/media/movie_5'); |
| video.play(); |
| |
| }, 'Test new callbacks are only called on the next frame.'); |
| |
| async_test(function(t) { |
| let video = document.createElement('video'); |
| |
| let numberOfCallsLeft = 10; |
| let lastPresentedFrames = -1; |
| |
| function frameNumberVerifier(time, metadata) { |
| assert_greater_than(metadata.presentedFrames, lastPresentedFrames, "presentedFrames should be monotonically increasing"); |
| |
| lastPresentedFrames = metadata.presentedFrames; |
| |
| if (--numberOfCallsLeft) { |
| t.done() |
| } else { |
| video.requestAnimationFrame(t.step_func(frameNumberVerifier)); |
| } |
| } |
| |
| video.requestAnimationFrame(t.step_func(frameNumberVerifier)); |
| |
| video.src = getVideoURI('/media/movie_5'); |
| video.play(); |
| |
| }, 'Test chaining calls to video.rAF.'); |
| </script> |
| </html> |