Bug 1208316 - Add dummy audio track in pure video track test. r?jib draft
authorAndreas Pehrson <pehrsons@gmail.com>
Fri, 09 Sep 2016 14:23:44 +0200
changeset 432205 46de8a01f5e66a8c5d9b43c50c24ab0ea47610ea
parent 432204 cd0307e27d12bb48b68849e16158498cdfc1e1e0
child 432206 1a831fa02c8a754ec7c87d7c4fb990ad3a01aebf
push id34233
push userbmo:pehrson@telenordigital.com
push dateTue, 01 Nov 2016 13:21:40 +0000
reviewersjib
bugs1208316
milestone52.0a1
Bug 1208316 - Add dummy audio track in pure video track test. r?jib This will keep the stream active and avoid the HTMLMediaElement ending. We could do it by repeatedly play()ing or autoplay, but then we wouldn't be sure the media element stopped rendering video because it went to the ended state or because there were no more frames in the track. MozReview-Commit-ID: 3CsvRPW7rrr
dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html
--- a/dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html
+++ b/dom/media/tests/mochitest/test_getUserMedia_mediaElementCapture_video.html
@@ -67,16 +67,24 @@ runTest(() => getUserMedia({video: true,
     gUMVideoElement.play();
 
     info("Capturing");
     captureStreamElement =
       createMediaElement("video", "captureStream");
     captureStreamElement.srcObject = gUMVideoElement.mozCaptureStream();
     captureStreamElement.play();
 
+    // Adding a dummy audio track to the stream will keep a consuming media
+    // element from ending.
+    // We could also solve it by repeatedly play()ing or autoplay, but then we
+    // wouldn't be sure the media element stopped rendering video because it
+    // went to the ended state or because there were no frames for the track.
+    let osc = createOscillatorStream(new AudioContext(), 1000);
+    captureStreamElement.srcObject.addTrack(osc.getTracks()[0]);
+
     return checkVideoPlaying(captureStreamElement);
   })
   .then(() => {
     info("Video flowing. Pausing.");
     gUMVideoElement.pause();
 
     return checkVideoPaused(captureStreamElement);
   })