1378826.html (1379B)
1 <!DOCTYPE html> 2 <html class="reftest-wait"> 3 <head> 4 <title>Bug 1378826 : Removing last video track from recorder stream crashes.</title> 5 </head> 6 <body> 7 <canvas id="canvas"></canvas> 8 <script type="text/javascript"> 9 10 function wait(ms) { 11 return new Promise(resolve => setTimeout(resolve, ms)); 12 } 13 14 function boom() { 15 let canvas = document.getElementById("canvas"); 16 let ctx = canvas.getContext('2d'); 17 ctx.fillRect(10, 10, 100, 100); 18 let stream = canvas.captureStream(); 19 let rec = new MediaRecorder(stream); 20 // At the time of fixing this bug onstop would fire, but this may change in 21 // future. As such defensively listen for onerror too to prevent this test 22 // timing out. 23 let stoppedPromise = new Promise(y => (rec.onstop = y, 24 rec.onerror = e => y)); 25 rec.onstart = () => { 26 // Remove the video track from the stream we're recording 27 stream.removeTrack(stream.getTracks()[0]); 28 // Recorder should stop or error in response to the above 29 return stoppedPromise 30 .then(() => { 31 // Little wait to help get bad writes if they're going to happen 32 wait(100) 33 .then(() => { 34 // Didn't crash, finish 35 document.documentElement.removeAttribute("class"); 36 }); 37 }); 38 }; 39 rec.start(); 40 } 41 42 window.onload = boom; 43 44 </script> 45 </body> 46 </html>