| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <title>Test the video.requestVideoFrameCallback() API for non visible video elements.</title> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script src="/common/media.js"></script> |
| 7 | <body> |
| 8 | </body> |
| 9 | <script> |
| 10 | var testVideo = { |
| 11 | url: getVideoURI('/media/movie_5'), |
| 12 | height: 240, |
| 13 | width: 320, |
| 14 | } |
| 15 | |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 16 | promise_test(async function(t) { |
| 17 | let done; |
| 18 | const promise = new Promise(resolve => done = resolve); |
| 19 | |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 20 | let video = document.createElement('video'); |
| 21 | |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 22 | video.requestVideoFrameCallback(done); |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 23 | video.src = testVideo.url; |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 24 | await video.play(); |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 25 | |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 26 | return promise; |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 27 | }, 'Test a video outside of the DOM can still use video.rVFC.'); |
| 28 | |
| 29 | function rvfcStyleTest(applyStyle, description) { |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 30 | promise_test(async function(t) { |
| 31 | let done; |
| 32 | const promise = new Promise(resolve => done = resolve); |
| 33 | |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 34 | let video = document.createElement('video'); |
| 35 | document.body.appendChild(video); |
| 36 | applyStyle(video); |
| 37 | |
| 38 | video.requestVideoFrameCallback( |
| 39 | t.step_func( _ => { |
| 40 | // Make sure we can receive more than one callback. |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 41 | video.requestVideoFrameCallback(done); |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 42 | }) |
| 43 | ); |
| 44 | |
| 45 | video.src = testVideo.url; |
| youennf | 9e70bad | 2021-11-18 07:34:24 | [diff] [blame] | 46 | await video.play(); |
| 47 | |
| 48 | return promise; |
| Thomas Guilbert | da0a378 | 2020-05-21 00:49:33 | [diff] [blame] | 49 | }, description); |
| 50 | } |
| 51 | |
| 52 | rvfcStyleTest((video) => { video.style.display = "none"}, |
| 53 | 'Test video.rVFC works with "display:none".'); |
| 54 | |
| 55 | rvfcStyleTest((video) => { video.style.visibility = "hidden"}, |
| 56 | 'Test video.rVFC works with "visibility:hidden".'); |
| 57 | |
| 58 | </script> |
| 59 | </html> |