summaryrefslogtreecommitdiffstats
path: root/dom/media/test/reftest/short.mp4.lastframe.html
blob: abd27c5c8eeb5b61e56cd369d9ed649bcb03e5f7 (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
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
<script type="text/javascript">
function doTest() {
  var video = document.getElementById("v1");
  video.src = "../short.mp4";
  video.preload = "metadata";
  video.seenEnded = false;
  // Seek to the end
  video.addEventListener("loadeddata", function() {
    video.currentTime = video.duration;
    video.onseeked = () => {
      video.onseeked = null;
      callSeekToNextFrame();
    };
  });

  function callSeekToNextFrame() {
    video.seekToNextFrame().then(
      () => {
        if (!video.seenEnded)
          callSeekToNextFrame();
      },
      () => {
        // Reach the end, do nothing.
      }
    );
  }

  video.addEventListener("ended", function() {
    video.seenEnded = true;
    document.documentElement.removeAttribute('class');
  });
}
window.addEventListener("MozReftestInvalidate", doTest);
</script>
</head>
<body>
<video id="v1" style="position:absolute; left:0; top:0"></video>
</body>
</html>