author Jean-Yves Avenard <>
Tue, 08 Dec 2015 15:05:50 -0500
changeset 276092 37003d495f204a65bd7647e56cd9d651bc125b5e
parent 257388 f462e2965b450bf5af19831d743fe6492aa154a0
child 276153 672a8b656e19b41617692bb1bc9b03a17beb4b3a
permissions -rw-r--r--
Bug 1229987: P3. Update mochitests and add new one verifying behavior. r=cpearce

<!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
  <title>MSE: |waiting| event when source data is missing</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" />
<pre id="test"><script class="testbody" type="text/javascript">


runWithMSE(function(ms, el) {
  el.controls = true;
  once(ms, 'sourceopen').then(function() {
    ok(true, "Receive a sourceopen event");
    var audiosb = ms.addSourceBuffer("audio/mp4");
    var videosb = ms.addSourceBuffer("video/mp4");
    fetchAndLoad(audiosb, 'bipbop/bipbop_audio', ['init'], '.mp4')
    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', ['init'], '.mp4'))
    .then(fetchAndLoad.bind(null, audiosb, 'bipbop/bipbop_audio', range(1, 5), '.m4s'))
    .then(fetchAndLoad.bind(null, videosb, 'bipbop/bipbop_video', range(1, 6), '.m4s'))
    .then(function() {
      // HTMLMediaElement fires 'waiting' if somebody invokes |play()| before the MDSM
      // has notified it of available data. Make sure that we get 'playing' before
      // we starting waiting for 'waiting'.
      info("Invoking play()");
      var p = once(el, 'playing');;
      return p;
    }).then(function() {
      ok(true, "Video playing. It should play for a bit, then fire 'waiting'");
      var p = once(el, 'waiting');;
      return p;
    }).then(function() {
      // currentTime is based on the current video frame, so if the audio ends just before
      // the next video frame, currentTime can be up to 1 frame's worth earlier than
      // min(audioEnd, videoEnd).
      // Some decoders (Windows in particular) may keep up to 25 frames queued.
      isfuzzy(el.currentTime, Math.min(audiosb.buffered.end(0), videosb.buffered.end(0)) - 1/30,
              0.04, "Got a waiting event at " + el.currentTime);
      var p = once(el, 'ended');
      return p;
    }).then(function() {
      is(el.duration, 4.005, "Video has correct duration: " + el.duration);
      is(el.currentTime, el.duration, "Video has correct currentTime.");