summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_seamless_looping_resume_video_decoding.html
blob: e9e4778d72ea2d42fb20a98968b618b072640078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE HTML>
<html>
<head>
<title>Seamless looping test with resuming video decoding</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="manifest.js"></script>
<script src="background_video.js"></script>
</head>
<script type="application/javascript">

/**
 * This test aims to check if seamless looping can work well with the mechanism
 * of resuming video decoding. When resuming decoding, MDSM will leave the
 * looping state and go to video only seek state. We want to ensure that the
 * timestamp of new video data that state requests will also be adjusted in
 * order to keep video playback ongoing without video being frozen because
 * frames get discarded.
 */
add_task(async function testSeamlessLoopingResumeVideoDecoding() {
  await SpecialPowers.pushPrefEnv({
    set: [
      ["media.test.video-suspend", true],
      ["media.suspend-bkgnd-video.enabled", true],
      ["media.suspend-bkgnd-video.delay-ms", 0],
    ],
  });

  info(`create video and play it`);
  let video = document.createElement('video');
  video.loop = true;
  video.src = "gizmo.mp4";
  document.body.appendChild(video);
  // speed up the test.
  video.playbackRate = 2;
  await video.play();

  info(`test seamless looping once`);
  await once(video, "seeked");
  ok(true, `loop back happened`);

  info(`suspend video decoding`);
  video.setVisible(false);
  await nextVideoSuspends(video);
  info(`suspended video decoding`);

  info(`resume video decoding (enter video-only seek state)`);
  video.setVisible(true);
  await testVideoOnlySeekCompletedWhenShown(video);
  info(`resumed video decoding and finished video-only seeking`);

  const lastPaintedFramesAmount = video.mozPaintedFrames;
  info(`end test after looping one more time`);
  await once(video, "seeked");

  const currentPaintedFrameAmount  = video.mozPaintedFrames;
  ok(lastPaintedFramesAmount < currentPaintedFrameAmount,
      `painted frames keeps growing from ${lastPaintedFramesAmount} to ${currentPaintedFrameAmount}`);
});

</script>
<body>
</body>
</html>