blob: e05c8d57bc3426707c7a542e18a3a6d6e002196b [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>enumerateDevices: test that enumerateDevices is present</title>
<link rel="author" title="Dr Alex Gouaillard" href="mailto:agouaillard@gmail.com"/>
<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#methods-2">
<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#device-info">
<link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaDeviceKind">
<meta name='assert' content='Check that the enumerateDevices() method is present.'/>
</head>
<body>
<h1 class="instructions">Description</h1>
<p class="instructions">This test checks for the presence of the
<code>navigator.mediaDevices.enumerateDevices()</code> method.</p>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
<script>
"use strict";
idl_test(
['mediacapture-main'],
['dom', 'html'],
async idl_array => {
assert_true(undefined !== navigator.mediaDevices.enumerateDevices,
"navigator.mediaDevices.enumerateDevices exists");
const list = await navigator.mediaDevices.enumerateDevices();
if( list.length > 0 ) {
window._mediaInfo = list[0];
idl_array.add_objects({MediaDeviceInfo: ["_mediaInfo"]});
}
for(const media of list) {
if( media.kind == "audioinput" ||
media.kind == "videoinput") {
// TODO -- Check InputDeviceInfo IDL, getCapabilities()
} else if ( media.kind == "audiooutput" ) {
// TODO -- pass
} else {
assert_unreached("media.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.")
}
}
}
);
</script>
</body>
</html>