summaryrefslogtreecommitdiffstats
path: root/dom/media/webrtc/tests/mochitests/test_getUserMedia_active_autoplay.html
blob: c1a39cdd4ccec0b5fa046d545845459c82d47b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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>