blob: c1804b4edd0c986aa161dfc13179983c04ace404 [file] [log] [blame]
Thomas Guilbertda0a3782020-05-21 00:49:331<!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>
10var testVideo = {
11 url: getVideoURI('/media/movie_5'),
12 height: 240,
13 width: 320,
14}
15
youennf9e70bad2021-11-18 07:34:2416promise_test(async function(t) {
17 let done;
18 const promise = new Promise(resolve => done = resolve);
19
Thomas Guilbertda0a3782020-05-21 00:49:3320 let video = document.createElement('video');
21
youennf9e70bad2021-11-18 07:34:2422 video.requestVideoFrameCallback(done);
Thomas Guilbertda0a3782020-05-21 00:49:3323 video.src = testVideo.url;
youennf9e70bad2021-11-18 07:34:2424 await video.play();
Thomas Guilbertda0a3782020-05-21 00:49:3325
youennf9e70bad2021-11-18 07:34:2426 return promise;
Thomas Guilbertda0a3782020-05-21 00:49:3327}, 'Test a video outside of the DOM can still use video.rVFC.');
28
29function rvfcStyleTest(applyStyle, description) {
youennf9e70bad2021-11-18 07:34:2430 promise_test(async function(t) {
31 let done;
32 const promise = new Promise(resolve => done = resolve);
33
Thomas Guilbertda0a3782020-05-21 00:49:3334 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.
youennf9e70bad2021-11-18 07:34:2441 video.requestVideoFrameCallback(done);
Thomas Guilbertda0a3782020-05-21 00:49:3342 })
43 );
44
45 video.src = testVideo.url;
youennf9e70bad2021-11-18 07:34:2446 await video.play();
47
48 return promise;
Thomas Guilbertda0a3782020-05-21 00:49:3349 }, description);
50}
51
52rvfcStyleTest((video) => { video.style.display = "none"},
53 'Test video.rVFC works with "display:none".');
54
55rvfcStyleTest((video) => { video.style.visibility = "hidden"},
56 'Test video.rVFC works with "visibility:hidden".');
57
58</script>
59</html>