Bug 1294605 - Add explicit test case. r=jib draft
authorAndreas Pehrson <pehrsons@gmail.com>
Tue, 30 Aug 2016 14:24:33 +0200
changeset 428038 9bf16d60ef7175e67eefa067ef57dba0d6c9d350
parent 428037 32d8f86300fce5b2b1b6df9ac57d0cc9d66198aa
child 428039 53a16d3fac963070f943935437d062ca7b245ea9
push id33215
push userbmo:pehrson@telenordigital.com
push dateFri, 21 Oct 2016 13:47:09 +0000
reviewersjib
bugs1294605
milestone52.0a1
Bug 1294605 - Add explicit test case. r=jib MozReview-Commit-ID: 9MJn7QQ9siZ
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_getUserMedia_trackCloneCleanup.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -75,16 +75,17 @@ skip-if = android_version == '18' # andr
 [test_getUserMedia_playVideoTwice.html]
 [test_getUserMedia_spinEventLoop.html]
 [test_getUserMedia_stopAudioStream.html]
 [test_getUserMedia_stopAudioStreamWithFollowupAudio.html]
 [test_getUserMedia_stopVideoAudioStream.html]
 [test_getUserMedia_stopVideoAudioStreamWithFollowupVideoAudio.html]
 [test_getUserMedia_stopVideoStream.html]
 [test_getUserMedia_stopVideoStreamWithFollowupVideo.html]
+[test_getUserMedia_trackCloneCleanup.html]
 [test_getUserMedia_trackEnded.html]
 [test_getUserMedia_peerIdentity.html]
 [test_peerConnection_addIceCandidate.html]
 [test_peerConnection_addtrack_removetrack_events.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_basicAudio.html]
 skip-if = (android_version == '18') # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_peerConnection_basicAudioNATSrflx.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_getUserMedia_trackCloneCleanup.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
+</head>
+<body>
+<pre id="test">
+<script type="application/javascript">
+  "use strict";
+
+  createHTML({
+    title: "Stopping a MediaStreamTrack and its clones should deallocate the device",
+    bug: "1294605"
+  });
+
+  runTest(() => getUserMedia({audio: true, video: true}).then(stream => {
+    let clone = stream.clone();
+    stream.getTracks().forEach(t => t.stop());
+    stream.clone().getTracks().forEach(t => stream.addTrack(t));
+    is(stream.getTracks().filter(t => t.readyState == "live").length, 0,
+       "Cloning ended tracks should make them ended");
+    [...stream.getTracks(), ...clone.getTracks()].forEach(t => t.stop());
+
+    // Bug 1295352: better to be explicit about noGum here wrt future refactoring.
+    return noGum();
+  }));
+</script>
+</pre>
+</body>
+</html>