Bug 1208316 - Test that a MediaStream becoming active triggers autoplay. r=jib
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 14 Sep 2016 10:11:46 +0200
changeset 320643 b52349c52e061676b860e5d89d566003755fa564
parent 320642 a20a1d0d0c0e27af3acd33a12c561fd6d306a932
child 320644 7414623c1788783ddd718459837954691071b109
push id30902
push userphilringnalda@gmail.com
push dateThu, 03 Nov 2016 02:30:31 +0000
treeherdermozilla-central@ade8d4a63e57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1208316
milestone52.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 1208316 - Test that a MediaStream becoming active triggers autoplay. r=jib MozReview-Commit-ID: 9F3MXiLGrvA
dom/media/tests/mochitest/mochitest.ini
dom/media/tests/mochitest/test_getUserMedia_active_autoplay.html
--- a/dom/media/tests/mochitest/mochitest.ini
+++ b/dom/media/tests/mochitest/mochitest.ini
@@ -36,16 +36,17 @@ skip-if = android_version == '18' # andr
 [test_dataChannel_basicVideo.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_dataChannel_bug1013809.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_dataChannel_noOffer.html]
 [test_enumerateDevices.html]
 [test_ondevicechange.html]
 skip-if = os == 'android'
+[test_getUserMedia_active_autoplay.html]
 [test_getUserMedia_audioCapture.html]
 skip-if = android_version == '18' # android(Bug 1189784, timeouts on 4.3 emulator)
 [test_getUserMedia_addTrackRemoveTrack.html]
 [test_getUserMedia_addtrack_removetrack_events.html]
 [test_getUserMedia_basicAudio.html]
 [test_getUserMedia_basicVideo.html]
 [test_getUserMedia_basicVideo_playAfterLoadedmetadata.html]
 [test_getUserMedia_basicScreenshare.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/tests/mochitest/test_getUserMedia_active_autoplay.html
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <script type="application/javascript" src="mediaStreamPlayback.js"></script>
+</head>
+<body>
+<pre id="test">
+<video id="testAutoplay" autoplay></video>
+<script type="application/javascript">
+"use strict";
+
+const video = document.getElementById("testAutoplay");
+var stream;
+var otherVideoTrack;
+var otherAudioTrack;
+
+createHTML({
+  title: "MediaStream can be autoplayed in media element after going inactive and then active",
+  bug: "1208316"
+});
+
+runTest(() => getUserMedia({audio: true, video: true}).then(s => {
+  stream = s;
+  otherVideoTrack = stream.getVideoTracks()[0].clone();
+  otherAudioTrack = stream.getAudioTracks()[0].clone();
+
+  video.srcObject = stream;
+  return haveEvent(video, "playing", wait(5000, new Error("Timeout")));
+})
+.then(() => {
+  ok(!video.ended, "Video element should be playing after adding a gUM stream");
+  stream.getTracks().forEach(t => t.stop());
+  return haveEvent(video, "ended", wait(5000, new Error("Timeout")));
+})
+.then(() => {
+  ok(video.ended, "Video element should be ended");
+  stream.addTrack(otherVideoTrack);
+  return haveEvent(video, "playing", wait(5000, new Error("Timeout")));
+})
+.then(() => {
+  ok(!video.ended, "Video element should be playing after adding a video track");
+  stream.getTracks().forEach(t => t.stop());
+  return haveEvent(video, "ended", wait(5000, new Error("Timeout")));
+})
+.then(() => {
+  ok(video.ended, "Video element should be ended");
+  stream.addTrack(otherAudioTrack);
+  return haveEvent(video, "playing", wait(5000, new Error("Timeout")));
+})
+.then(() => {
+  ok(!video.ended, "Video element should be playing after adding a audio track");
+  stream.getTracks().forEach(t => t.stop());
+  return haveEvent(video, "ended", wait(5000, new Error("Timeout")));
+})
+.then(() => {
+  ok(video.ended, "Video element should be ended");
+}));
+</script>
+</pre>
+</body>
+</html>