test_peerConnection_capturedVideo.html (2216B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script src="pc.js"></script> 5 <script src="../../../test/manifest.js"></script> 6 </head> 7 <body> 8 <pre id="test"> 9 <script type="application/javascript"> 10 (async () => { 11 await createHTML({ 12 bug: "1081409", 13 title: "Captured video-only over peer connection", 14 visible: true 15 }); 16 17 // Run tests in sequence for log readability. 18 PARALLEL_TESTS = 1; 19 const manager = new MediaTestManager; 20 21 async function startTest(media, token) { 22 manager.started(token); 23 info(`Starting test for ${media.name}`); 24 const video = document.createElement('video'); 25 video.id = "id_" + media.name; 26 video.width = 160; 27 video.height = 120; 28 video.muted = true; 29 video.controls = true; 30 video.preload = "metadata"; 31 video.src = "../../../test/" + media.name; 32 33 document.getElementById("content").appendChild(video); 34 35 const onerror = new Promise(r => video.onerror = r).then(_ => 36 new Error(`${media.name} failed in playback. code=${video.error.code}`)); 37 38 await Promise.race([ 39 new Promise(res => video.onloadedmetadata = res), 40 onerror, 41 ]); 42 onerror.catch(e => ok(false, e)); 43 setupEnvironment(); 44 await testConfigured; 45 const stream = video.mozCaptureStream(); 46 const test = new PeerConnectionTest( 47 { 48 config_local: { label_suffix: media.name }, 49 config_remote: { label_suffix: media.name }, 50 } 51 ); 52 test.setOfferOptions( 53 { 54 offerToReceiveVideo: false, 55 offerToReceiveAudio: false, 56 } 57 ); 58 const hasVideo = !!stream.getVideoTracks().length; 59 const hasAudio = !!stream.getAudioTracks().length; 60 test.setMediaConstraints([{ video: hasVideo, audio: hasAudio }], []); 61 test.chain.replace("PC_LOCAL_GUM", [ 62 function PC_LOCAL_CAPTUREVIDEO(test) { 63 test.pcLocal.attachLocalStream(stream); 64 }, 65 ]); 66 test.chain.insertBefore("PC_LOCAL_WAIT_FOR_MEDIA_FLOW", [ 67 function PC_LOCAL_START_MEDIA(test) { 68 video.play(); 69 }, 70 ]); 71 await test.run(); 72 removeNodeAndSource(video); 73 manager.finished(token); 74 } 75 76 manager.runTests(getPlayableVideos(gLongerTests), startTest); 77 })(); 78 </script> 79 </pre> 80 </body> 81 </html>