MediaDevices-enumerateDevices-not-allowed-camera.https.html (1632B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>enumerateDevices: test enumerateDevices should not expose camera devices if they are not allowed by Permissions-Policy header</title> 5 <link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices"> 6 <meta name='assert' content='Check that the enumerateDevices() method should not expose camera devices when blocked by Permissions-Policy.'/> 7 </head> 8 <body> 9 <h1 class="instructions">Description</h1> 10 <p class="instructions">This test checks for the absence of camera in 11 <code>navigator.mediaDevices.enumerateDevices()</code> method when blocked by the Permissions-Policy header.</p> 12 <div id='log'></div> 13 <script src=/resources/testharness.js></script> 14 <script src=/resources/testharnessreport.js></script> 15 <script> 16 "use strict"; 17 promise_test(async () => { 18 assert_not_equals(navigator.mediaDevices.enumerateDevices, undefined, "navigator.mediaDevices.enumerateDevices exists"); 19 const deviceList = await navigator.mediaDevices.enumerateDevices(); 20 for (const mediaInfo of deviceList) { 21 assert_not_equals(mediaInfo.deviceId, undefined, "mediaInfo's deviceId should exist."); 22 assert_not_equals(mediaInfo.kind, undefined, "mediaInfo's kind should exist."); 23 assert_not_equals(mediaInfo.label, undefined, "mediaInfo's label should exist."); 24 assert_not_equals(mediaInfo.groupId, undefined, "mediaInfo's groupId should exist."); 25 assert_in_array(mediaInfo.kind, ["audioinput", "audiooutput"]); 26 } 27 }, "Camera is not exposed in mediaDevices.enumerateDevices() when blocked by Permissions-Policy header"); 28 </script> 29 </body> 30 </html>