summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasource/test/test_EndOfStream.html
blob: 655d21cd320bca76ed0ec1087ccecd54f7824ed8 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>MSE: endOfStream call after an appendBuffer</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="mediasource.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">

SimpleTest.waitForExplicitFinish();

runWithMSE(function () {
  var ms = new MediaSource();

  var v = document.createElement("video");
  v.src = URL.createObjectURL(ms);
  document.body.appendChild(v);

  ms.addEventListener("sourceopen", function () {
    var sb = ms.addSourceBuffer("video/webm");

    fetchWithXHR("seek.webm", function (arrayBuffer) {
      sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 88966));
      var count = 0;
      sb.addEventListener("updateend", function () {
        ++count;
        if (count == 1) {
          setTimeout(function() {
                       var fail = false;
                       try {
                         ms.endOfStream();
                       } catch (e) {
                         fail = true;
                       }
                       ok(!fail, "MediaSource.endOfStream succeeded");
                       SimpleTest.finish();
                     }, 0);
        }
      });
    });
  });
});

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