MediaDevices-enumerateDevices-persistent-permission.https.html (1649B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>enumerateDevices depends only on capture state, not permission state</title> 5 <script src=/resources/testharness.js></script> 6 <script src=/resources/testharnessreport.js></script> 7 <script src=/resources/testdriver.js></script> 8 <script src=/resources/testdriver-vendor.js></script> 9 <script src=permission-helper.js></script> 10 </head> 11 <body> 12 13 <script> 14 promise_test(async t => { 15 await setMediaPermission(); 16 const stream = await navigator.mediaDevices.getUserMedia({audio : true, video: true}); 17 stream.getTracks().forEach(t => t.stop()); 18 // the page loaded below hasn't had capture enabled 19 // so enumerateDevices should not list detailed info yet 20 const iframe = document.createElement("iframe"); 21 iframe.setAttribute("allow", "microphone;camera"); 22 iframe.src = "/mediacapture-streams/iframe-enumerate-nogum.html"; 23 document.body.appendChild(iframe); 24 const loadWatcher = new EventWatcher(t, iframe, ['load']); 25 await loadWatcher.wait_for('load'); 26 const msgWatcher = new EventWatcher(t, window, ['message']); 27 frames[0].postMessage('run', '*') 28 const e = await msgWatcher.wait_for('message'); 29 const iframeDevices = e.data.devices; 30 const kinds = iframeDevices.map(({kind}) => kind); 31 assert_equals(kinds.length, new Set(kinds).size, "At most one of a kind prior to capture"); 32 for (const device of iframeDevices) { 33 assert_equals(device.deviceId, "", "deviceId pre-capture is empty"); 34 assert_equals(device.label, "", "label pre-capture is empty"); 35 assert_equals(device.groupId, "", "groupId pre-capture is empty"); 36 } 37 }); 38 </script>