Bug 1161615: clean up gUM mochitest to use promises
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Fri, 08 May 2015 14:16:49 -0700
changeset 262143 3efb1ffdfe8a55dc9501b30c076c9480e840a1e1
parent 262140 cef2b76b082d36c329e94dfded65ead78ce026f2
child 550840 383be9d63e36caa029084b986064012d11b3e6bf
push id1956
push userdrno@ohlmeier.org
push dateFri, 08 May 2015 21:40:01 +0000
bugs1161615
milestone40.0a1
Bug 1161615: clean up gUM mochitest to use promises
dom/media/tests/mochitest/head.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_basicVideo_playAfterLoadedmetadata.html
dom/media/tests/mochitest/test_getUserMedia_basicWindowshare.html
dom/media/tests/mochitest/test_getUserMedia_callbacks.html
dom/media/tests/mochitest/test_getUserMedia_constraints.html
dom/media/tests/mochitest/test_getUserMedia_gumWithinGum.html
dom/media/tests/mochitest/test_getUserMedia_peerIdentity.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/head.js
+++ b/dom/media/tests/mochitest/head.js
@@ -110,18 +110,17 @@ function getUserMedia(constraints) {
     constraints["fake"] = FAKE_ENABLED;
   }
 
   info("Call getUserMedia for " + JSON.stringify(constraints));
   return navigator.mediaDevices.getUserMedia(constraints);
 }
 
 // These are the promises we use to track that the prerequisites for the test
-// are in place before running it.  Users of this file need to ensure that they
-// also provide a promise called `scriptsReady` as well.
+// are in place before running it.
 var setTestOptions;
 var testConfigured = new Promise(r => setTestOptions = r);
 
 function setupEnvironment() {
   if (!window.SimpleTest) {
     // Running under Steeplechase
     return;
   }
@@ -158,25 +157,20 @@ function run_test(is_initiator) {
   var s = document.createElement("script");
   s.src = "/test.js";
   s.onload = () => setTestOptions(options);
   document.head.appendChild(s);
 }
 
 function runTestWhenReady(testFunc) {
   setupEnvironment();
-  return Promise.all([scriptsReady, testConfigured]).then(() => {
-    try {
-      return testConfigured.then(options => testFunc(options));
-    } catch (e) {
-      ok(false, 'Error executing test: ' + e +
-         ((typeof e.stack === 'string') ?
-          (' ' + e.stack.split('\n').join(' ... ')) : ''));
-    }
-  });
+  return testConfigured.then(options => testFunc(options))
+    .catch(e => ok(false, 'Error executing test: ' + e +
+        ((typeof e.stack === 'string') ?
+        (' ' + e.stack.split('\n').join(' ... ')) : '')));
 }
 
 
 /**
  * Checks that the media stream tracks have the expected amount of tracks
  * with the correct kind and id based on the type and constraints given.
  *
  * @param {Object} constraints specifies whether the stream should have
--- a/dom/media/tests/mochitest/mediaStreamPlayback.js
+++ b/dom/media/tests/mochitest/mediaStreamPlayback.js
@@ -222,11 +222,15 @@ var scriptsReady = Promise.all([
   document.head.appendChild(el);
   return new Promise(r => el.onload = r);
 }));
 
 function createHTML(options) {
   return scriptsReady.then(() => realCreateHTML(options));
 }
 
-function runTest(f) {
-  return scriptsReady.then(() => runTestWhenReady(f));
-}
+var runTest = testFunction => scriptsReady
+  .then(() => runTestWhenReady(testFunction))
+  .then(() => finish())
+  .catch(e =>
+         ok(false, 'Error in test execution: ' + e +
+            ((typeof e.stack === 'string') ?
+             (' ' + e.stack.split('\n').join(' ... ')) : '')));
--- a/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicAudio.html
@@ -10,20 +10,20 @@
   /**
    * 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 = createMediaElement('audio', 'testAudio');
     var constraints = {audio: true};
 
-    getUserMedia(constraints).then(aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    return getUserMedia(constraints).then(stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testAudio, aStream);
+      var playback = new LocalMediaStreamPlayback(testAudio, stream);
       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
@@ -25,21 +25,21 @@
     var constraints = {
       video: {
          mozMediaSource: "screen",
          mediaSource: "screen"
       },
       fake: false
     };
 
-    getUserMedia(constraints).then(aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    return getUserMedia(constraints).then(stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testVideo, aStream);
+      var playback = new LocalMediaStreamPlayback(testVideo, stream);
       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
@@ -13,20 +13,20 @@
   /**
    * 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 = createMediaElement('video', 'testVideo');
     var constraints = {video: true};
 
-    getUserMedia(constraints).then(aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    return getUserMedia(constraints).then(stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testVideo, aStream);
+      var playback = new LocalMediaStreamPlayback(testVideo, stream);
       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
@@ -13,20 +13,20 @@
   /**
    * 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 = createMediaElement('video', 'testVideoAudio');
     var constraints = {video: true, audio: true};
 
-    getUserMedia(constraints).then(aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    return getUserMedia(constraints).then(stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testVideoAudio, aStream);
+      var playback = new LocalMediaStreamPlayback(testVideoAudio, stream);
       return playback.playMedia(false);
-    }).then(() => SimpleTest.finish(), generateErrorCallback());
+    });
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_basicVideo_playAfterLoadedmetadata.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_basicVideo_playAfterLoadedmetadata.html
@@ -13,31 +13,31 @@
   /**
    * Run a test to verify that we will always get 'loadedmetadata' from a video
    * HTMLMediaElement playing a gUM MediaStream.
    */
   runTest(() => {
     var testVideo = createMediaElement('video', 'testVideo');
     var constraints = {video: true};
 
-    getUserMedia(constraints).then(aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    return getUserMedia(constraints).then(stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testVideo, aStream);
+      var playback = new LocalMediaStreamPlayback(testVideo, stream);
       var video = playback.mediaElement;
 
-      video.mozSrcObject = aStream;
+      video.mozSrcObject = stream;
       return new Promise(resolve => {
         ok(playback.mediaElement.paused,
            "Media element should be paused before play()ing");
         video.addEventListener('loadedmetadata', function() {
           ok(video.videoWidth > 0, "Expected nonzero video width");
           ok(video.videoHeight > 0, "Expected nonzero video width");
           resolve();
         });
       });
-    }).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
@@ -25,21 +25,21 @@
     var constraints = {
       video: {
          mozMediaSource: "window",
          mediaSource: "window"
       },
       fake: false
     };
 
-    getUserMedia(constraints).then(aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    return getUserMedia(constraints).then(stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testVideo, aStream);
+      var playback = new LocalMediaStreamPlayback(testVideo, stream);
       return playback.playMediaWithStreamStop(false);
-    }).then(() => SimpleTest.finish(), generateErrorCallback());
+    });
 
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_callbacks.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_callbacks.html
@@ -13,21 +13,20 @@
   /**
    * Check that the old fashioned callback-based function works.
    */
   runTest(function () {
     var testAudio = createMediaElement('audio', 'testAudio');
     var constraints = {audio: true};
 
     SimpleTest.waitForExplicitFinish();
-    navigator.mozGetUserMedia(constraints, aStream => {
-      checkMediaStreamTracks(constraints, aStream);
+    navigator.mozGetUserMedia(constraints, stream => {
+      checkMediaStreamTracks(constraints, stream);
 
-      var playback = new LocalMediaStreamPlayback(testAudio, aStream);
-      return playback.playMedia(false)
-        .then(() => SimpleTest.finish(), generateErrorCallback());
+      var playback = new LocalMediaStreamPlayback(testAudio, stream);
+      return playback.playMedia(false);
     }, generateErrorCallback());
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_constraints.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_constraints.html
@@ -76,20 +76,18 @@ var tests = [
  */
 
 runTest(function() {
   var p = new Promise(resolve => SpecialPowers.pushPrefEnv({
       set : [ ['media.getusermedia.browser.enabled', false],
               ['media.getusermedia.screensharing.enabled', false] ]
     }, resolve));
 
-  tests.reduce((p, test) =>
+  return tests.reduce((p, test) =>
     p.then(() => navigator.mediaDevices.getUserMedia(test.constraints))
     .then(() => is(null, test.error, test.message),
-          e => is(e.name, test.error, test.message + ": " + e.message)), p)
-  .catch(e => ok(false, "Unexpected failure: " + e.name + ", " + e.message))
-  .then(SimpleTest.finish);
+          e => is(e.name, test.error, test.message + ": " + e.message)), p);
 });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_gumWithinGum.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_gumWithinGum.html
@@ -8,33 +8,32 @@
 <script type="application/javascript">
   createHTML({title: "getUserMedia within getUserMedia", bug: "822109" });
   /**
    * 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})
+    return getUserMedia({video: true})
       .then(videoStream => {
         var testVideo = createMediaElement('video', 'testVideo');
         var videoPlayback = new LocalMediaStreamPlayback(testVideo,
                                                          videoStream);
 
         return videoPlayback.playMedia(false)
           .then(() => getUserMedia({audio: true}))
           .then(audioStream => {
             var testAudio = createMediaElement('audio', 'testAudio');
             var audioPlayback = new LocalMediaStreamPlayback(testAudio,
                                                              audioStream);
 
             return audioPlayback.playMedia(false)
               .then(() => audioStream.stop());
           })
           .then(() => videoStream.stop());
-      })
-      .then(() => SimpleTest.finish(), generateErrorCallback());
+      });
   });
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_peerIdentity.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_peerIdentity.html
@@ -21,21 +21,18 @@ function theTest() {
     return getUserMedia(config)
       .then(stream => Promise.all([
         audioIsSilence(withConstraint, stream),
         videoIsBlack(withConstraint, stream)
       ]));
   };
 
   // both without and with the constraint
-  testPeerIdentityConstraint(false)
-    .then(() => testPeerIdentityConstraint(true))
-    .catch(e => ok(false, 'error in test: ' + e))
-    .then(() => SimpleTest.finish())
-    .catch(e => ok(false, 'something is really messed up: ' + e));
+  return testPeerIdentityConstraint(false)
+    .then(() => testPeerIdentityConstraint(true));
 }
 
 runTest(theTest);
 
 </script>
 </pre>
 </body>
 </html>
--- a/dom/media/tests/mochitest/test_getUserMedia_playAudioTwice.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_playAudioTwice.html
@@ -6,21 +6,21 @@
 <body>
 <pre id="test">
 <script type="application/javascript">
   createHTML({title: "getUserMedia Play Audio Twice", bug: "822109" });
   /**
    * Run a test that we can complete an audio playback cycle twice in a row.
    */
   runTest(function () {
-    getUserMedia({audio: true}).then(audioStream => {
+    return getUserMedia({audio: true}).then(audioStream => {
       var testAudio = createMediaElement('audio', 'testAudio');
       var playback = new LocalMediaStreamPlayback(testAudio, audioStream);
 
       return playback.playMedia(false)
         .then(() => playback.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
@@ -6,22 +6,22 @@
 <body>
 <pre id="test">
 <script type="application/javascript">
   createHTML({title: "getUserMedia Play Video and Audio Twice", bug: "822109" });
   /**
    * Run a test that we can complete a video playback cycle twice in a row.
    */
   runTest(function () {
-    getUserMedia({video: true, audio: true}).then(stream => {
+    return getUserMedia({video: true, audio: true}).then(stream => {
       var testVideo = createMediaElement('video', 'testVideo');
       var playback = new LocalMediaStreamPlayback(testVideo, stream);
 
       return playback.playMedia(false)
         .then(() => playback.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
@@ -6,22 +6,22 @@
 <body>
 <pre id="test">
 <script type="application/javascript">
   createHTML({ title: "getUserMedia Play Video Twice", bug: "822109" });
   /**
    * Run a test that we can complete a video playback cycle twice in a row.
    */
   runTest(function () {
-    getUserMedia({video: true}).then(stream => {
+    return getUserMedia({video: true}).then(stream => {
       var testVideo = createMediaElement('video', 'testVideo');
       var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
       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
@@ -7,22 +7,21 @@
 <pre id="test">
 <script type="application/javascript">
   createHTML({ title: "getUserMedia Stop Audio Stream", bug: "822109" });
   /**
    * 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})
+    return getUserMedia({audio: true})
       .then(stream => {
         var testAudio = createMediaElement('audio', 'testAudio');
         var streamPlayback = new LocalMediaStreamPlayback(testAudio, stream);
 
         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
@@ -8,29 +8,28 @@
 <script type="application/javascript">
   createHTML({ title: "getUserMedia Stop Audio Stream With Followup Audio", bug: "822109" });
   /**
    * 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})
+    return getUserMedia({audio: true})
       .then(firstStream => {
         var testAudio = createMediaElement('audio', 'testAudio');
         var streamPlayback = new LocalMediaStreamPlayback(testAudio, firstStream);
 
         return streamPlayback.playMediaWithStreamStop(false)
           .then(() => getUserMedia({audio: true}))
           .then(secondStream => {
             streamPlayback.mediaStream = secondStream;
 
             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
@@ -8,22 +8,21 @@
 <script type="application/javascript">
   createHTML({ title: "getUserMedia Stop Video Audio Stream", bug: "822109" });
   /**
    * 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})
+    return getUserMedia({video: true, audio: true})
       .then(stream => {
         var testVideo = createMediaElement('video', 'testVideo');
         var playback = new LocalMediaStreamPlayback(testVideo, stream);
 
         return playback.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
@@ -11,29 +11,28 @@
     bug: "822109"
   });
   /**
    * 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})
+    return getUserMedia({video: true, audio: true})
       .then(stream => {
         var testVideo = createMediaElement('video', 'testVideo');
         var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
         return streamPlayback.playMediaWithStreamStop(false)
           .then(() => getUserMedia({video: true, audio: true}))
           .then(secondStream => {
             streamPlayback.mediaStream = secondStream;
 
             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
@@ -8,22 +8,21 @@
 <script type="application/javascript">
   createHTML({ title: "getUserMedia Stop Video Stream", bug: "822109" });
   /**
    * 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})
+    return getUserMedia({video: true})
       .then(stream => {
         var testVideo = createMediaElement('video', 'testVideo');
         var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
         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
@@ -8,29 +8,28 @@
 <script type="application/javascript">
   createHTML({ title: "getUserMedia Stop Video Stream With Followup Video", bug: "822109" });
   /**
    * 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})
+    return getUserMedia({video: true})
       .then(stream => {
         var testVideo = createMediaElement('video', 'testVideo');
         var streamPlayback = new LocalMediaStreamPlayback(testVideo, stream);
 
         return streamPlayback.playMediaWithStreamStop(false)
           .then(() => getUserMedia({video: true}))
           .then(secondStream => {
             streamPlayback.mediaStream = secondStream;
 
             return streamPlayback.playMedia(false)
               .then(() => secondStream.stop());
           });
-      })
-      .then(() => SimpleTest.finish(), generateErrorCallback());
+      });
   });
 
 </script>
 </pre>
 </body>
 </html>