test_getUserMedia_getTrackById.html (1624B)
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 <script type="application/javascript"> 9 createHTML({ 10 title: "Basic getTrackById test of gUM stream", 11 bug: "1208390", 12 }); 13 14 runTest(() => { 15 var constraints = {audio: true, video: true}; 16 return getUserMedia(constraints).then(stream => { 17 is(stream.getTrackById(""), null, 18 "getTrackById of non-matching string should return null"); 19 20 let audioTrack = stream.getAudioTracks()[0]; 21 is(stream.getTrackById(audioTrack.id), audioTrack, 22 "getTrackById with matching id should return the track"); 23 24 let videoTrack = stream.getVideoTracks()[0]; 25 is(stream.getTrackById(videoTrack.id), videoTrack, 26 "getTrackById with matching id should return the track"); 27 28 stream.removeTrack(audioTrack); 29 is(stream.getTrackById(audioTrack.id), null, 30 "getTrackById with id of removed track should return null"); 31 32 let newStream = new MediaStream(); 33 is(newStream.getTrackById(videoTrack.id), null, 34 "getTrackById with id of track in other stream should return null"); 35 36 newStream.addTrack(audioTrack); 37 is(newStream.getTrackById(audioTrack.id), audioTrack, 38 "getTrackByid with matching id should return the track"); 39 40 newStream.addTrack(videoTrack); 41 is(newStream.getTrackById(videoTrack.id), videoTrack, 42 "getTrackByid with matching id should return the track"); 43 [audioTrack, videoTrack].forEach(t => t.stop()); 44 }); 45 }); 46 47 </script> 48 </pre> 49 </body> 50 </html>