summaryrefslogtreecommitdiffstats
path: root/dom/media/mediasource/test/test_SeekedEvent_mp4.html
blob: 70401f1eb1c8d0f7e07504554b455d7da058b762 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>MSE: Check that seeked event is fired prior loadeddata</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, el) => {
  el.controls = true;
  const events = ["seeked", "loadeddata", "playing"];
  let eventCount = 0;
  events.forEach(type => el.addEventListener(type,
      () => is(events[eventCount++], type, "events must come in order")));
  await once(ms, "sourceopen");
  ok(true, "Receive a sourceopen event");
  const videosb = ms.addSourceBuffer("video/mp4");
  is(el.readyState, el.HAVE_NOTHING, "readyState is HAVE_NOTHING");
  let p = once(el, "loadedmetadata");
  await fetchAndLoad(videosb, "bipbop/bipbop_video", ["init"], ".mp4");
  await p;
  el.play();
  videosb.timestampOffset = 2;
  is(el.readyState, el.HAVE_METADATA, "readyState is HAVE_METADATA");
  // Load [2, 3.606).
  p = once(el, "play");
  await fetchAndLoad(videosb, "bipbop/bipbop_video", ["1"], ".m4s");
  await p;
  await fetchAndLoad(videosb, "bipbop/bipbop_video", ["2"], ".m4s");
  // TODO: readyState should be at least HAVE_CURRENTDATA, see bug 1367993.
  ok(el.readyState >= el.HAVE_METADATA, "readyState is HAVE_METADATA");
  el.currentTime = 2;
  await Promise.all([once(el, "seeked"), once(el, "playing")]);
  ok(true, "completed seek");
  is(eventCount, events.length, "Received expected number of events");
  SimpleTest.finish();
});

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