test_groupId.html (1830B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script src="mediaStreamPlayback.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <script type="application/javascript"> 9 createHTML({ title: "Test group id of MediaDeviceInfo", bug: "1213453" }); 10 11 async function getDefaultDevices() { 12 const devices = await navigator.mediaDevices.enumerateDevices(); 13 14 devices.forEach(d => isnot(d.groupId, "", "GroupId is included in every device")); 15 16 const videos = devices.filter(d => d.kind == "videoinput"); 17 is(videos.length, 1, "One video device found."); 18 const audios = devices.filter(d => d.kind == "audioinput"); 19 is(audios.length, 1, "One microphone device found."); 20 21 return {audio: audios[0], video: videos[0]}; 22 } 23 24 runTest(async () => { 25 // Force fake devices in order to be able to change camera name by pref. 26 await pushPrefs(["media.navigator.streams.fake", true], 27 ["media.audio_loopback_dev", ""], 28 ["media.video_loopback_dev", ""]); 29 30 const afterGum = await navigator.mediaDevices.getUserMedia({ 31 video: true, audio: true 32 }); 33 afterGum.getTracks().forEach(track => track.stop()); 34 35 let {audio, video} = await getDefaultDevices(); 36 37 /* The low level method to correlate groupIds is by device names. 38 * Use a similar comparison here to verify that it works. 39 * Multiple devices of the same device name are not expected in 40 * automation. */ 41 isnot(audio.label, video.label, "Audio label differs from video"); 42 isnot(audio.groupId, video.groupId, "Not the same groupIds"); 43 // Change video name to match. 44 await pushPrefs(["media.getusermedia.fake-camera-name", audio.label]); 45 ({audio, video} = await getDefaultDevices()); 46 is(audio.label, video.label, "Audio label matches video"); 47 is(audio.groupId, video.groupId, "GroupIds should be the same"); 48 }); 49 </script> 50 </pre> 51 </body> 52 </html>