Revision 7208979a308347c4379e0669b83de1a013176a2b authored by Yutaka Hirano on 24 April 2018, 07:30:37 UTC, committed by Yutaka Hirano on 24 April 2018, 07:30:37 UTC
1 parent 5acf250
MediaDevices-IDL-enumerateDevices.html
<!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";
function doIdlTest(idlText) {
const MDI_idl = new IdlArray();
MDI_idl.add_untested_idls("interface Event {};");
MDI_idl.add_untested_idls("interface EventTarget {};");
MDI_idl.add_untested_idls("interface Navigator {};");
MDI_idl.add_idls(idlText);
assert_true(undefined !== navigator.mediaDevices.enumerateDevices,
"navigator.mediaDevices.enumerateDevices exists");
return navigator.mediaDevices.enumerateDevices()
.then(function(list) {
if( list.length > 0 ) {
var kind = list[0].kind;
if (kind == "audioinput" ||
kind == "videoinput") {
MDI_idl.add_objects({InputDeviceInfo: [list[0]]});
} else if (kind == "audiooutput" ) {
MDI_idl.add_objects({MediaDeviceInfo: [list[0]]});
}
}
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'.")
}
}
MDI_idl.test();
});
}
promise_test(() => {
return fetch('/interfaces/mediacapture-main.idl')
.then(response => response.text())
.then(doIdlTest);
}, "Test MediaDevices.enumerateDevices call and result. Types only.");
</script>
</body>
</html>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...