<!doctype html>
<html>
<head>
<title>enumerateDevices: test enumerateDevices should not expose camera devices if they are not allowed by Permissions-Policy header</title>
<link rel="help" href="https://w3c.github.io/mediacapture-main/#dom-mediadevices-enumeratedevices">
<meta name='assert' content='Check that the enumerateDevices() method should not expose camera devices when blocked by Permissions-Policy.'/>
</head>
<body>
<h1 class="instructions">Description</h1>
<p class="instructions">This test checks for the absence of camera in
<code>navigator.mediaDevices.enumerateDevices()</code> method when blocked by the Permissions-Policy header.</p>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
"use strict";
promise_test(async () => {
  assert_not_equals(navigator.mediaDevices.enumerateDevices, undefined, "navigator.mediaDevices.enumerateDevices exists");
  const deviceList =  await navigator.mediaDevices.enumerateDevices();
  for (const mediaInfo of deviceList) {
    assert_not_equals(mediaInfo.deviceId, undefined, "mediaInfo's deviceId should exist.");
    assert_not_equals(mediaInfo.kind, undefined,     "mediaInfo's kind     should exist.");
    assert_not_equals(mediaInfo.label, undefined,    "mediaInfo's label    should exist.");
    assert_not_equals(mediaInfo.groupId, undefined,  "mediaInfo's groupId  should exist.");
    assert_in_array(mediaInfo.kind, ["audioinput", "audiooutput"]);
  }
}, "Camera is not exposed in mediaDevices.enumerateDevices() when blocked by Permissions-Policy header");
</script>
</body>
</html>
