Bug 1294605 - Add explicit test case. r=jib
MozReview-Commit-ID: 9MJn7QQ9siZ
--- 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>