author Bryce Van Dyk <>
Mon, 14 May 2018 10:08:59 -0400
changeset 418748 abc9351a9c159afb31d58fc29beda855ad4f832b
parent 276092 37003d495f204a65bd7647e56cd9d651bc125b5e
child 420382 5f5b118631b0a235a75c90c16b75db31d0de0cf0
permissions -rw-r--r--
Bug 1461785 - Update dom/media/mediasource/test to abide eslint rules, add .eslintrc.js. r=jya,standard8 Add .eslintrc.js to configure globals from mediasource.js and to add extra rules to encourage use of let and const over var. Linting changes: - Prefer const and let to var. This provides tighter scoping and avoids reassignment. - Mozilla rules do not allow for shadowing of variables, so several tests have had promise lists renamed to avoid this. - Numerous minor fixes to formatting including using double quotes, spacing, missing semicolons. - Remove some unused variables. - Arrays have spaces after opening braces and before closing braces, e.g. [ "foo" ], this is to be consistent with our clang-format rules. - Fix naming of resourcePathSeen in test_MediaSource_memory_reporting.html. MozReview-Commit-ID: 5q6oS7EWLTk

<!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");
    const videosb = ms.addSourceBuffer("video/mp4");
    fetchAndLoad(videosb, "bipbop/bipbop_video", [ "init" ], ".mp4")
    .then(function() {
      // Set appendWindowEnd to ensure we only have about 6 frames worth.
      // We must feed at least 6 frames to pass the MDSM pre-roll.
      videosb.appendWindowEnd = .4;
      return fetchAndLoad(videosb, "bipbop/bipbop_video", [ "1" ], ".m4s");
    .then(function() {
      info("Invoking play()");
      const promises = [];
      promises.push(once(el, "playing"));;
      return Promise.all(promises);
    .then(function() {
      info("got playing");
      return once(el, "waiting");
    }).then(function() {
      info("got waiting");
      info("Loading more data");
      // Waiting will be fired on the last frame +- 40ms.
      isfuzzy(el.currentTime, videosb.buffered.end(0) - 1 / 30,
              0.04, "Got a waiting event at " + el.currentTime);
      videosb.appendWindowEnd = 1;
      const p = once(el, "ended");
      const loads = fetchAndLoad(videosb, "bipbop/bipbop_video", [ 1 ], ".m4s");
      loads.then(() => ms.endOfStream());
      return p;
    }).then(function() {
      // These fuzz factors are bigger than they should be. We should investigate
      // and fix them in bug 1137574.
      is(el.duration, 0.801666, "Video has correct duration: " + el.duration);
      is(el.currentTime, el.duration, "Video has correct currentTime.");