Bug 1119593 - Update gUM tests to use promises consistently, r=drno,jib
☠☠ backed out by a2984f1964f6 ☠ ☠
authorMartin Thomson <martin.thomson@gmail.com>
Tue, 27 Jan 2015 12:35:58 -0800
changeset 253255 4ccecd0da80ffc40f25a211395d7ca31a8847a9c
parent 253254 2ea753b42366d177d4f6af7abc5484e4819c4951
child 253256 f7f0adc1879df19224511d9fbdb9f77a76aaf297
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno, jib
bugs1119593
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1119593 - Update gUM tests to use promises consistently, r=drno,jib Conflicts: dom/media/tests/mochitest/constraints.js
dom/media/tests/mochitest/constraints.js
dom/media/tests/mochitest/mediaStreamPlayback.js
dom/media/tests/mochitest/test_getUserMedia_basicAudio.html
dom/media/tests/mochitest/test_getUserMedia_basicScreenshare.html
dom/media/tests/mochitest/test_getUserMedia_basicVideo.html
dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html
dom/media/tests/mochitest/test_getUserMedia_basicWindowshare.html
dom/media/tests/mochitest/test_getUserMedia_gumWithinGum.html
dom/media/tests/mochitest/test_getUserMedia_playAudioTwice.html
dom/media/tests/mochitest/test_getUserMedia_playVideoAudioTwice.html
dom/media/tests/mochitest/test_getUserMedia_playVideoTwice.html
dom/media/tests/mochitest/test_getUserMedia_stopAudioStream.html
dom/media/tests/mochitest/test_getUserMedia_stopAudioStreamWithFollowupAudio.html
dom/media/tests/mochitest/test_getUserMedia_stopVideoAudioStream.html
dom/media/tests/mochitest/test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html
dom/media/tests/mochitest/test_getUserMedia_stopVideoStream.html
dom/media/tests/mochitest/test_getUserMedia_stopVideoStreamWithFollowupVideo.html
--- a/dom/media/tests/mochitest/constraints.js
+++ b/dom/media/tests/mochitest/constraints.js
@@ -65,30 +65,23 @@ var common_tests = [
 
 
 /**
  * Starts the test run by running through each constraint
  * test by verifying that the right resolution and rejection is fired.
  */
 
 function testConstraints(tests) {
-  function testgum(p, test) {
-    return p.then(function() {
-      return navigator.mediaDevices.getUserMedia(test.constraints);
-    })
-    .then(function() {
-      is(null, test.error, test.message);
-    }, function(reason) {
-      is(reason.name, test.error, test.message + ": " + reason.message);
-    });
+  function testgum(prev, test) {
+    return prev.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
+      .then(() => is(null, test.error, test.message),
+            reason => is(reason.name, test.error, test.message + ": " + reason.message));
   }
 
-  var p = new Promise(r => SpecialPowers.pushPrefEnv({
-      set : [ ['media.getusermedia.browser.enabled', false],
-              ['media.getusermedia.screensharing.enabled', false] ]
-    }, r));
+  var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
+    set : [ ['media.getusermedia.browser.enabled', false],
+            ['media.getusermedia.screensharing.enabled', false] ]
+  }, resolve));
 
-  tests.forEach(function(test) {
-    p = testgum(p, test);
-  });
-  p.catch(reason => ok(false, "Unexpected failure: " + reason.message))
-  .then(SimpleTest.finish);
+  tests.reduce(testgum, p)
+    .catch(reason => ok(false, "Unexpected failure: " + reason.message))
+    .then(SimpleTest.finish);
 }
--- a/dom/media/tests/mochitest/mediaStreamPlayback.js
+++ b/dom/media/tests/mochitest/mediaStreamPlayback.js
@@ -32,137 +32,123 @@ MediaStreamPlayback.prototype = {
    *
    * @param {Boolean} isResume specifies if this media element is being resumed
    *                           from a previous run
    * @param {Function} onSuccess the success callback if the media playback
    *                             start and stop cycle completes successfully
    * @param {Function} onError the error callback if the media playback
    *                           start and stop cycle fails
    */
-  playMedia : function MSP_playMedia(isResume, onSuccess, onError) {
-    var self = this;
-
-    this.startMedia(isResume, function() {
-      self.stopMediaElement();
-      onSuccess();
-    }, onError);
+  playMedia : function(isResume) {
+    return this.startMedia(isResume)
+      .then(() => this.stopMediaElement());
   },
 
   /**
    * Starts the media with the associated stream.
    *
    * @param {Boolean} isResume specifies if the media element playback
    *                           is being resumed from a previous run
-   * @param {Function} onSuccess the success function call back
-   *                             if media starts correctly
-   * @param {Function} onError the error function call back
-   *                           if media fails to start
    */
-  startMedia : function MSP_startMedia(isResume, onSuccess, onError) {
-    var self = this;
+  startMedia : function(isResume) {
     var canPlayThroughFired = false;
 
     // If we're initially running this media, check that the time is zero
     if (!isResume) {
       is(this.mediaStream.currentTime, 0,
          "Before starting the media element, currentTime = 0");
     }
 
-    /**
-     * Callback fired when the canplaythrough event is fired. We only
-     * run the logic of this function once, as this event can fire
-     * multiple times while a HTMLMediaStream is playing content from
-     * a real-time MediaStream.
-     */
-    var canPlayThroughCallback = function() {
-      // Disable the canplaythrough event listener to prevent multiple calls
-      canPlayThroughFired = true;
-      self.mediaElement.removeEventListener('canplaythrough',
-        canPlayThroughCallback, false);
+    return new Promise((resolve, reject) => {
+      /**
+       * Callback fired when the canplaythrough event is fired. We only
+       * run the logic of this function once, as this event can fire
+       * multiple times while a HTMLMediaStream is playing content from
+       * a real-time MediaStream.
+       */
+      var canPlayThroughCallback = () => {
+        // Disable the canplaythrough event listener to prevent multiple calls
+        canPlayThroughFired = true;
+        this.mediaElement.removeEventListener('canplaythrough',
+                                              canPlayThroughCallback, false);
 
-      is(self.mediaElement.paused, false,
-        "Media element should be playing");
-      is(self.mediaElement.duration, Number.POSITIVE_INFINITY,
-        "Duration should be infinity");
+        is(this.mediaElement.paused, false,
+           "Media element should be playing");
+        is(this.mediaElement.duration, Number.POSITIVE_INFINITY,
+           "Duration should be infinity");
 
-      // When the media element is playing with a real-time stream, we
-      // constantly switch between having data to play vs. queuing up data,
-      // so we can only check that the ready state is one of those two values
-      ok(self.mediaElement.readyState === HTMLMediaElement.HAVE_ENOUGH_DATA ||
-         self.mediaElement.readyState === HTMLMediaElement.HAVE_CURRENT_DATA,
-         "Ready state shall be HAVE_ENOUGH_DATA or HAVE_CURRENT_DATA");
+        // When the media element is playing with a real-time stream, we
+        // constantly switch between having data to play vs. queuing up data,
+        // so we can only check that the ready state is one of those two values
+        ok(this.mediaElement.readyState === HTMLMediaElement.HAVE_ENOUGH_DATA ||
+           this.mediaElement.readyState === HTMLMediaElement.HAVE_CURRENT_DATA,
+           "Ready state shall be HAVE_ENOUGH_DATA or HAVE_CURRENT_DATA");
+
+        is(this.mediaElement.seekable.length, 0,
+           "Seekable length shall be zero");
+        is(this.mediaElement.buffered.length, 0,
+           "Buffered length shall be zero");
 
-      is(self.mediaElement.seekable.length, 0,
-         "Seekable length shall be zero");
-      is(self.mediaElement.buffered.length, 0,
-         "Buffered length shall be zero");
+        is(this.mediaElement.seeking, false,
+           "MediaElement is not seekable with MediaStream");
+        ok(isNaN(this.mediaElement.startOffsetTime),
+           "Start offset time shall not be a number");
+        is(this.mediaElement.loop, false, "Loop shall be false");
+        is(this.mediaElement.preload, "", "Preload should not exist");
+        is(this.mediaElement.src, "", "No src should be defined");
+        is(this.mediaElement.currentSrc, "",
+           "Current src should still be an empty string");
 
-      is(self.mediaElement.seeking, false,
-         "MediaElement is not seekable with MediaStream");
-      ok(isNaN(self.mediaElement.startOffsetTime),
-         "Start offset time shall not be a number");
-      is(self.mediaElement.loop, false, "Loop shall be false");
-      is(self.mediaElement.preload, "", "Preload should not exist");
-      is(self.mediaElement.src, "", "No src should be defined");
-      is(self.mediaElement.currentSrc, "",
-         "Current src should still be an empty string");
+        var timeUpdateCallback = () => {
+          if (this.mediaStream.currentTime > 0 &&
+              this.mediaElement.currentTime > 0) {
+            this.mediaElement.removeEventListener('timeupdate',
+                                                  timeUpdateCallback, false);
+            resolve();
+          }
+        };
 
-      var timeUpdateFired = false;
+        // When timeupdate fires, we validate time has passed and move
+        // onto the success condition
+        this.mediaElement.addEventListener('timeupdate', timeUpdateCallback,
+                                           false);
 
-      var timeUpdateCallback = function() {
-        if (self.mediaStream.currentTime > 0 &&
-            self.mediaElement.currentTime > 0) {
-          timeUpdateFired = true;
-          self.mediaElement.removeEventListener('timeupdate',
-            timeUpdateCallback, false);
-          onSuccess();
-        }
+        // If timeupdate doesn't fire in enough time, we fail the test
+        setTimeout(() => {
+          this.mediaElement.removeEventListener('timeupdate',
+                                                timeUpdateCallback, false);
+          reject(new Error("timeUpdate event never fired"));
+        }, TIMEUPDATE_TIMEOUT_LENGTH);
       };
 
-      // When timeupdate fires, we validate time has passed and move
-      // onto the success condition
-      self.mediaElement.addEventListener('timeupdate', timeUpdateCallback,
-        false);
-
-      // If timeupdate doesn't fire in enough time, we fail the test
-      setTimeout(function() {
-        if (!timeUpdateFired) {
-          self.mediaElement.removeEventListener('timeupdate',
-            timeUpdateCallback, false);
-          onError("timeUpdate event never fired");
-        }
-      }, TIMEUPDATE_TIMEOUT_LENGTH);
-    };
+      // Adds a listener intended to be fired when playback is available
+      // without further buffering.
+      this.mediaElement.addEventListener('canplaythrough', canPlayThroughCallback,
+                                         false);
 
-    // Adds a listener intended to be fired when playback is available
-    // without further buffering.
-    this.mediaElement.addEventListener('canplaythrough', canPlayThroughCallback,
-      false);
-
-    // Hooks up the media stream to the media element and starts playing it
-    this.mediaElement.mozSrcObject = this.mediaStream;
-    this.mediaElement.play();
+      // Hooks up the media stream to the media element and starts playing it
+      this.mediaElement.mozSrcObject = this.mediaStream;
+      this.mediaElement.play();
 
-    // If canplaythrough doesn't fire in enough time, we fail the test
-    setTimeout(function() {
-      if (!canPlayThroughFired) {
-        self.mediaElement.removeEventListener('canplaythrough',
-          canPlayThroughCallback, false);
-        onError("canplaythrough event never fired");
-      }
-    }, CANPLAYTHROUGH_TIMEOUT_LENGTH);
+      // If canplaythrough doesn't fire in enough time, we fail the test
+      setTimeout(() => {
+        this.mediaElement.removeEventListener('canplaythrough',
+                                              canPlayThroughCallback, false);
+        reject(new Error("canplaythrough event never fired"));
+      }, CANPLAYTHROUGH_TIMEOUT_LENGTH);
+    });
   },
 
   /**
    * Stops the media with the associated stream.
    *
    * Precondition: The media stream and element should both be actively
    *               being played.
    */
-  stopMediaElement : function MSP_stopMediaElement() {
+  stopMediaElement : function() {
     this.mediaElement.pause();
     this.mediaElement.mozSrcObject = null;
   }
 }
 
 
 /**
  * This class is basically the same as MediaStreamPlayback except
@@ -181,69 +167,49 @@ function LocalMediaStreamPlayback(mediaE
 LocalMediaStreamPlayback.prototype = Object.create(MediaStreamPlayback.prototype, {
 
   /**
    * Starts media with a media stream, runs it until a canplaythrough and
    * timeupdate event fires, and calls stop() on the stream.
    *
    * @param {Boolean} isResume specifies if this media element is being resumed
    *                           from a previous run
-   * @param {Function} onSuccess the success callback if the media element
-   *                             successfully fires ended on a stop() call
-   *                             on the stream
-   * @param {Function} onError the error callback if the media element fails
-   *                           to fire an ended callback on a stop() call
-   *                           on the stream
    */
   playMediaWithStreamStop : {
-    value: function (isResume, onSuccess, onError) {
-      var self = this;
-
-      this.startMedia(isResume, function() {
-        self.stopStreamInMediaPlayback(function() {
-          self.stopMediaElement();
-          onSuccess();
-        }, onError);
-      }, onError);
+    value: function(isResume) {
+      return this.startMedia(isResume)
+        .then(() => this.stopStreamInMediaPlayback())
+        .then(() => this.stopMediaElement());
     }
   },
 
   /**
    * Stops the local media stream while it's currently in playback in
    * a media element.
    *
    * Precondition: The media stream and element should both be actively
    *               being played.
    *
-   * @param {Function} onSuccess the success callback if the media element
-   *                             fires an ended event from stop() being called
-   * @param {Function} onError the error callback if the media element
-   *                           fails to fire an ended event from stop() being
-   *                           called
    */
   stopStreamInMediaPlayback : {
-    value: function (onSuccess, onError) {
-      var endedFired = false;
-      var self = this;
+    value: function () {
+      return new Promise((resolve, reject) => {
+        /**
+         * Callback fired when the ended event fires when stop() is called on the
+         * stream.
+         */
+        var endedCallback = () => {
+          this.mediaElement.removeEventListener('ended', endedCallback, false);
+          ok(true, "ended event successfully fired");
+          resolve();
+        };
 
-      /**
-       * Callback fired when the ended event fires when stop() is called on the
-       * stream.
-       */
-      var endedCallback = function() {
-        endedFired = true;
-        self.mediaElement.removeEventListener('ended', endedCallback, false);
-        ok(true, "ended event successfully fired");
-        onSuccess();
-      };
+        this.mediaElement.addEventListener('ended', endedCallback, false);
+        this.mediaStream.stop();
 
-      this.mediaElement.addEventListener('ended', endedCallback, false);
-      this.mediaStream.stop();
-
-      // If ended doesn't fire in enough time, then we fail the test
-      setTimeout(function() {
-        if (!endedFired) {
-          onError("ended event never fired");
-        }
-      }, ENDED_TIMEOUT_LENGTH);
+        // If ended doesn't fire in enough time, then we fail the test
+        setTimeout(() => {
+          reject(new Error("ended event never fired"));
+        }, ENDED_TIMEOUT_LENGTH);
+      });
     }
   }
 });
--- a/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html
@@ -1,46 +1,41 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=781534
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Basic Audio Test</title>
+  <title>getUserMedia Basic Audio Test</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">mozGetUserMedia Basic Audio Test</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">getUserMedia Basic Audio Test</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <audio id="testAudio"></audio>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that we can complete a start and stop media playback
    * cycle for an audio LocalMediaStream on an audio HTMLMediaElement.
    */
   runTest(function () {
     var testAudio = document.getElementById('testAudio');
     var constraints = {audio: true};
 
-    getUserMedia(constraints, function (aStream) {
+    getUserMedia(constraints).then(aStream => {
       checkMediaStreamTracks(constraints, aStream);
 
       var playback = new LocalMediaStreamPlayback(testAudio, aStream);
-      playback.playMedia(false, function () {
-        aStream.stop();
-        SimpleTest.finish();
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
-
+      return playback.playMedia(false);
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_basicScreenshare.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicScreenshare.html
@@ -1,23 +1,23 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=983504
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Basic Screenshare Test</title>
+  <title>getUserMedia Basic Screenshare Test</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=983504">mozGetUserMedia Basic Screenshare Test</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=983504">getUserMedia Basic Screenshare Test</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that we can complete a start and stop media playback
@@ -34,25 +34,21 @@ https://bugzilla.mozilla.org/show_bug.cg
     var constraints = {
       video: {
          mozMediaSource: "screen",
          mediaSource: "screen"
       },
       fake: false
     };
 
-    getUserMedia(constraints, function (aStream) {
+    getUserMedia(constraints).then(aStream => {
       checkMediaStreamTracks(constraints, aStream);
 
       var playback = new LocalMediaStreamPlayback(testVideo, aStream);
-      playback.playMediaWithStreamStop(false, function () {
-        aStream.stop();
-        SimpleTest.finish();
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+      return playback.playMediaWithStreamStop(false);
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
 
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_basicVideo.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicVideo.html
@@ -1,46 +1,41 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=781534
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Basic Video Test</title>
+  <title>getUserMedia Basic Video Test</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">mozGetUserMedia Basic Video Test</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">getUserMedia Basic Video Test</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that we can complete a start and stop media playback
    * cycle for an video LocalMediaStream on a video HTMLMediaElement.
    */
   runTest(function () {
     var testVideo = document.getElementById('testVideo');
     var constraints = {video: true};
 
-    getUserMedia(constraints, function (aStream) {
+    getUserMedia(constraints).then(aStream => {
       checkMediaStreamTracks(constraints, aStream);
 
       var playback = new LocalMediaStreamPlayback(testVideo, aStream);
-      playback.playMedia(false, function () {
-        aStream.stop();
-        SimpleTest.finish();
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
-
+      return playback.playMedia(false);
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicVideoAudio.html
@@ -1,45 +1,41 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=781534
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Basic Video & Audio Test</title>
+  <title>getUserMedia Basic Video & Audio Test</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">mozGetUserMedia Basic Video & Audio Test</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=781534">getUserMedia Basic Video & Audio Test</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideoAudio"></video>
 </div>
 <pre id="test">
-<script type="application/javascript">
+  <script type="application/javascript">
   /**
    * Run a test to verify that we can complete a start and stop media playback
    * cycle for a video and audio LocalMediaStream on a video HTMLMediaElement.
    */
   runTest(function () {
     var testVideoAudio = document.getElementById('testVideoAudio');
     var constraints = {video: true, audio: true};
 
-    getUserMedia(constraints, function (aStream) {
+    getUserMedia(constraints).then(aStream => {
       checkMediaStreamTracks(constraints, aStream);
 
       var playback = new LocalMediaStreamPlayback(testVideoAudio, aStream);
-      playback.playMedia(false, function () {
-        aStream.stop();
-        SimpleTest.finish();
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+      return playback.playMedia(false);
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_basicWindowshare.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicWindowshare.html
@@ -1,23 +1,23 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=983504
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Basic Windowshare Test</title>
+  <title>getUserMedia Basic Windowshare Test</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1038926">mozGetUserMedia Basic Windowshare Test</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1038926">getUserMedia Basic Windowshare Test</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that we can complete a start and stop media playback
@@ -34,25 +34,21 @@ https://bugzilla.mozilla.org/show_bug.cg
     var constraints = {
       video: {
          mozMediaSource: "window",
          mediaSource: "window"
       },
       fake: false
     };
 
-    getUserMedia(constraints, function (aStream) {
+    getUserMedia(constraints).then(aStream => {
       checkMediaStreamTracks(constraints, aStream);
 
       var playback = new LocalMediaStreamPlayback(testVideo, aStream);
-      playback.playMediaWithStreamStop(false, function () {
-        aStream.stop();
-        SimpleTest.finish();
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+      return playback.playMediaWithStreamStop(false);
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
 
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_gumWithinGum.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_gumWithinGum.html
@@ -1,56 +1,53 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia gum within gum</title>
+  <title>getUserMedia gum within gum</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia gum within gum</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia gum within gum</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
   <audio id="testAudio"></audio>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test that we can complete a playback cycle for a video,
    * then upon completion, do a playback cycle with audio, such that
    * the audio gum call happens within the video gum call.
    */
   runTest(function () {
-    getUserMedia({video: true}, function(videoStream) {
-      var testVideo = document.getElementById('testVideo');
-      var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo,
-        videoStream);
-
-      videoStreamPlayback.playMedia(false, function() {
-        getUserMedia({audio: true}, function(audioStream) {
-          var testAudio = document.getElementById('testAudio');
-          var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio,
-            audioStream);
+    getUserMedia({video: true})
+      .then(videoStream => {
+        var testVideo = document.getElementById('testVideo');
+        var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo,
+                                                               videoStream);
 
-          audioStreamPlayback.playMedia(false, function() {
-            audioStream.stop();
-            videoStream.stop();
-            SimpleTest.finish();
-          }, generateErrorCallback());
+        return videoStreamPlayback.playMedia(false)
+          .then(() => getUserMedia({audio: true}))
+          .then(audioStream => {
+            var testAudio = document.getElementById('testAudio');
+            var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio,
+                                                                   audioStream);
 
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+            return audioStreamPlayback.playMedia(false)
+              .then(() => audioStream.stop());
+          })
+          .then(() => videoStream.stop());
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_playAudioTwice.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_playAudioTwice.html
@@ -1,46 +1,39 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Play Audio Twice</title>
+  <title>getUserMedia Play Audio Twice</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Play Audio Twice</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Play Audio Twice</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <audio id="testAudio"></audio>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test that we can complete an audio playback cycle twice in a row.
    */
   runTest(function () {
-    getUserMedia({audio: true}, function(audioStream) {
+    getUserMedia({audio: true}).then(audioStream => {
       var testAudio = document.getElementById('testAudio');
       var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio,
         audioStream);
 
-      audioStreamPlayback.playMedia(false, function() {
-
-        audioStreamPlayback.playMedia(true, function() {
-          audioStream.stop();
-          SimpleTest.finish();
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+      return audioStreamPlayback.playMedia(false)
+        .then(() => audioStreamPlayback.playMedia(true))
+        .then(() => audioStream.stop());
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
   });
-
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_playVideoAudioTwice.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_playVideoAudioTwice.html
@@ -1,45 +1,39 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Play Video and Audio Twice</title>
+  <title>getUserMedia Play Video and Audio Twice</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Play Video and Audio Twice</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Play Video and Audio Twice</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test that we can complete a video playback cycle twice in a row.
    */
   runTest(function () {
-    getUserMedia({video: true, audio: true}, function(stream) {
+    getUserMedia({video: true, audio: true}).then(stream => {
       var testVideo = document.getElementById('testVideo');
       var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
-      streamPlayback.playMedia(false, function() {
-
-        streamPlayback.playMedia(true, function() {
-          stream.stop();
-          SimpleTest.finish();
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+      return streamPlayback.playMedia(false)
+        .then(() => streamPlayback.playMedia(true))
+        .then(() => stream.stop());
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_playVideoTwice.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_playVideoTwice.html
@@ -1,46 +1,39 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Play Video Twice</title>
+  <title>getUserMedia Play Video Twice</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Play Video Twice</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Play Video Twice</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test that we can complete a video playback cycle twice in a row.
    */
   runTest(function () {
-    getUserMedia({video: true}, function(videoStream) {
+    getUserMedia({video: true}).then(stream => {
       var testVideo = document.getElementById('testVideo');
-      var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo,
-        videoStream);
-
-      videoStreamPlayback.playMedia(false, function() {
+      var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
-        videoStreamPlayback.playMedia(true, function() {
-          videoStream.stop();
-          SimpleTest.finish();
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+      return streamPlayback.playMedia(false)
+        .then(() => streamPlayback.playMedia(true))
+        .then(() => stream.stop());
+    }).then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_stopAudioStream.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_stopAudioStream.html
@@ -1,39 +1,40 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Stop Audio Stream</title>
+  <title>getUserMedia Stop Audio Stream</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Audio Stream</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Audio Stream</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <audio id="testAudio"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that we can start an audio stream in a media element,
    * call stop() on the stream, and successfully get an ended event fired.
    */
   runTest(function () {
-    getUserMedia({audio: true}, function(stream) {
-      var testAudio = document.getElementById('testAudio');
-      var audioStreamPlayback = new LocalMediaStreamPlayback(testAudio, stream);
+    getUserMedia({audio: true})
+      .then(stream => {
+        var testAudio = document.getElementById('testAudio');
+        var streamPlayback = new LocalMediaStreamPlayback(testAudio, stream);
 
-      audioStreamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
-        generateErrorCallback());
-    }, generateErrorCallback());
+        return streamPlayback.playMediaWithStreamStop(false);
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_stopAudioStreamWithFollowupAudio.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_stopAudioStreamWithFollowupAudio.html
@@ -1,51 +1,48 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Stop Audio Stream With Followup Audio</title>
+  <title>getUserMedia Stop Audio Stream With Followup Audio</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Audio Stream With Followup Audio</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Audio Stream With Followup Audio</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <audio id="testAudio"></audio>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that I can complete an audio gum playback in a media
    * element, stop the stream, and then complete another audio gum playback
    * in a media element.
    */
   runTest(function () {
-    getUserMedia({audio: true}, function(firstStream) {
-      var testAudio = document.getElementById('testAudio');
-      var streamPlayback = new LocalMediaStreamPlayback(testAudio, firstStream);
-
-      streamPlayback.playMediaWithStreamStop(false, function() {
-        getUserMedia({audio: true}, function(secondStream) {
-          streamPlayback.mediaStream = secondStream;
+    getUserMedia({audio: true})
+      .then(firstStream => {
+        var testAudio = document.getElementById('testAudio');
+        var streamPlayback = new LocalMediaStreamPlayback(testAudio, firstStream);
 
-          streamPlayback.playMedia(false, function() {
-            secondStream.stop();
-            SimpleTest.finish();
-          }, generateErrorCallback());
+        return streamPlayback.playMediaWithStreamStop(false)
+          .then(() => getUserMedia({audio: true}))
+          .then(secondStream => {
+            streamPlayback.mediaStream = secondStream;
 
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+            return streamPlayback.playMedia(false)
+              .then(() => secondStream.stop());
+          });
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_stopVideoAudioStream.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_stopVideoAudioStream.html
@@ -1,40 +1,41 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Stop Video Audio Stream</title>
+  <title>getUserMedia Stop Video Audio Stream</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video Audio Stream</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video Audio Stream</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that we can start a video+audio stream in a
    * media element, call stop() on the stream, and successfully get an
    * ended event fired.
    */
   runTest(function () {
-    getUserMedia({video: true, audio: true}, function(stream) {
-      var testVideo = document.getElementById('testVideo');
-      var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
+    getUserMedia({video: true, audio: true})
+      .then(stream => {
+        var testVideo = document.getElementById('testVideo');
+        var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
-      streamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
-        generateErrorCallback());
-    }, generateErrorCallback());
+        return streamPlayback.playMediaWithStreamStop(false);
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html
@@ -1,51 +1,48 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Stop Video+Audio Stream With Followup Video+Audio</title>
+  <title>getUserMedia Stop Video+Audio Stream With Followup Video+Audio</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video+Audio Stream With Followup Video+Audio</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video+Audio Stream With Followup Video+Audio</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
    * Run a test to verify that I can complete an video+audio gum playback in a
    * media element, stop the stream, and then complete another video+audio gum
    * playback in a media element.
    */
   runTest(function () {
-    getUserMedia({video: true, audio: true}, function(firstStream) {
-      var testVideo = document.getElementById('testVideo');
-      var streamPlayback = new LocalMediaStreamPlayback(testVideo, firstStream);
-
-      streamPlayback.playMediaWithStreamStop(false, function() {
-        getUserMedia({video: true, audio: true}, function(secondStream) {
-          streamPlayback.mediaStream = secondStream;
+    getUserMedia({video: true, audio: true})
+      .then(stream => {
+        var testVideo = document.getElementById('testVideo');
+        var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
-          streamPlayback.playMedia(false, function() {
-            secondStream.stop();
-            SimpleTest.finish();
-          }, generateErrorCallback());
+        return streamPlayback.playMediaWithStreamStop(false)
+          .then(() => getUserMedia({video: true, audio: true}))
+          .then(secondStream => {
+            streamPlayback.mediaStream = secondStream;
 
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+            return streamPlayback.playMedia(false)
+              .then(() => secondStream.stop());
+          });
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_stopVideoStream.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_stopVideoStream.html
@@ -1,39 +1,41 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Stop Video Stream</title>
+  <title>getUserMedia Stop Video Stream</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video Stream</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video Audio Stream</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
-   * Run a test to verify that we can start a video stream in a media element,
-   * call stop() on the stream, and successfully get an ended event fired.
+   * Run a test to verify that we can start a video stream in a
+   * media element, call stop() on the stream, and successfully get an
+   * ended event fired.
    */
   runTest(function () {
-    getUserMedia({video: true}, function(stream) {
-      var testVideo = document.getElementById('testVideo');
-      var videoStreamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
+    getUserMedia({video: true})
+      .then(stream => {
+        var testVideo = document.getElementById('testVideo');
+        var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
-      videoStreamPlayback.playMediaWithStreamStop(false, SimpleTest.finish,
-        generateErrorCallback());
-    }, generateErrorCallback());
+        return streamPlayback.playMediaWithStreamStop(false);
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_stopVideoStreamWithFollowupVideo.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_stopVideoStreamWithFollowupVideo.html
@@ -1,52 +1,48 @@
-<!DOCTYPE HTML>
+<!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=822109
 -->
 <head>
   <meta charset="utf-8">
-  <title>mozGetUserMedia Stop Video Stream With Followup Video</title>
+  <title>getUserMedia Stop Video Stream With Followup Video</title>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="application/javascript" src="head.js"></script>
   <script type="application/javascript" src="mediaStreamPlayback.js"></script>
 </head>
 <body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">mozGetUserMedia Stop Video Stream With Followup Video</a>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822109">getUserMedia Stop Video Stream With Followup Video</a>
 <p id="display"></p>
 <div id="content" style="display: none">
   <video id="testVideo"></video>
 </div>
 <pre id="test">
 <script type="application/javascript">
   /**
-   * Run a test to verify that I can complete an audio gum playback in a media
-   * element, stop the stream, and then complete another audio gum playback
-   * in a media element.
+   * Run a test to verify that I can complete an video gum playback in a
+   * media element, stop the stream, and then complete another video gum
+   * playback in a media element.
    */
   runTest(function () {
-    getUserMedia({video: true}, function(firstStream) {
-      var testVideo = document.getElementById('testVideo');
-      var streamPlayback = new LocalMediaStreamPlayback(testVideo,
-        firstStream);
-
-      streamPlayback.playMediaWithStreamStop(false, function() {
-        getUserMedia({video: true}, function(secondStream) {
-          streamPlayback.mediaStream = secondStream;
+    getUserMedia({video: true})
+      .then(stream => {
+        var testVideo = document.getElementById('testVideo');
+        var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
-          streamPlayback.playMedia(false, function() {
-            secondStream.stop();
-            SimpleTest.finish();
-          }, generateErrorCallback());
+        return streamPlayback.playMediaWithStreamStop(false)
+          .then(() => getUserMedia({video: true}))
+          .then(secondStream => {
+            streamPlayback.mediaStream = secondStream;
 
-        }, generateErrorCallback());
-
-      }, generateErrorCallback());
-
-    }, generateErrorCallback());
+            return streamPlayback.playMedia(false)
+              .then(() => secondStream.stop());
+          });
+      })
+      .then(() => SimpleTest.finish(), generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>