test_getUserMedia_active_autoplay.html (1874B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="mediaStreamPlayback.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <video id="testAutoplay" autoplay></video> 9 <script type="application/javascript"> 10 "use strict"; 11 12 const video = document.getElementById("testAutoplay"); 13 var stream; 14 var otherVideoTrack; 15 var otherAudioTrack; 16 17 createHTML({ 18 title: "MediaStream can be autoplayed in media element after going inactive and then active", 19 bug: "1208316" 20 }); 21 22 runTest(() => getUserMedia({audio: true, video: true}).then(s => { 23 stream = s; 24 otherVideoTrack = stream.getVideoTracks()[0].clone(); 25 otherAudioTrack = stream.getAudioTracks()[0].clone(); 26 27 video.srcObject = stream; 28 return haveEvent(video, "playing", wait(5000, new Error("Timeout"))); 29 }) 30 .then(() => { 31 ok(!video.ended, "Video element should be playing after adding a gUM stream"); 32 stream.getTracks().forEach(t => t.stop()); 33 return haveEvent(video, "ended", wait(5000, new Error("Timeout"))); 34 }) 35 .then(() => { 36 ok(video.ended, "Video element should be ended"); 37 stream.addTrack(otherVideoTrack); 38 return haveEvent(video, "playing", wait(5000, new Error("Timeout"))); 39 }) 40 .then(() => { 41 ok(!video.ended, "Video element should be playing after adding a video track"); 42 stream.getTracks().forEach(t => t.stop()); 43 return haveEvent(video, "ended", wait(5000, new Error("Timeout"))); 44 }) 45 .then(() => { 46 ok(video.ended, "Video element should be ended"); 47 stream.addTrack(otherAudioTrack); 48 return haveEvent(video, "playing", wait(5000, new Error("Timeout"))); 49 }) 50 .then(() => { 51 ok(!video.ended, "Video element should be playing after adding a audio track"); 52 stream.getTracks().forEach(t => t.stop()); 53 return haveEvent(video, "ended", wait(5000, new Error("Timeout"))); 54 }) 55 .then(() => { 56 ok(video.ended, "Video element should be ended"); 57 })); 58 </script> 59 </pre> 60 </body> 61 </html>