summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasource/test/test_OnEvents.html
blob: ae0f348ebecebb4e0b05fe6831ba7f7045e83af6 (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>
<head>
  <title>MSE: live seekable range</title>
  <script 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(async (ms, v) => {
  const receiveEvent = e => v["got" + e] = true;

  const msevents = ["onsourceopen", "onsourceended"];
  msevents.forEach(e => ms[e] = () => receiveEvent(e));

  const sblistevents = ["onaddsourcebuffer", "onremovesourcebuffer"];
  sblistevents.forEach(e => ms.sourceBuffers[e] = () => receiveEvent(e));

  await once(ms, "sourceopen");
  const sb = ms.addSourceBuffer("video/webm");

  const sbevents = ["onupdatestart", "onupdate", "onupdateend", "onabort"];
  sbevents.forEach(e => sb[e] = () => receiveEvent(e));

  await fetchAndLoad(sb, "seek", [""], ".webm");
  sb.appendBuffer(await fetchWithXHR("seek.webm"));
  ms.removeSourceBuffer(sb); // will fire abort and removesourcebuffer
  ms.endOfStream(); // will fire sourceended
  await once(ms, "sourceended");
  [...msevents, ...sbevents, ...sblistevents].forEach(e => ok(v["got" + e], "got " + e));
  SimpleTest.finish();
});

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