e05c8d57bc3426707c7a542e18a3a6d6e002196b
[WebKit-https.git] / LayoutTests / imported / w3c / web-platform-tests / mediacapture-streams / MediaDevices-IDL-enumerateDevices.html
1 <!doctype html>
2 <html>
3 <head>
4 <title>enumerateDevices: test that enumerateDevices is present</title>
5 <link rel="author" title="Dr Alex Gouaillard" href="mailto:agouaillard@gmail.com"/>
6 <link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#methods-2">
7 <link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#device-info">
8 <link rel="help" href="http://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-MediaDeviceKind">
9 <meta name='assert' content='Check that the enumerateDevices() method is present.'/>
10 </head>
11 <body>
12 <h1 class="instructions">Description</h1>
13 <p class="instructions">This test checks for the presence of the
14 <code>navigator.mediaDevices.enumerateDevices()</code> method.</p>
15 <div id='log'></div>
16 <script src=/resources/testharness.js></script>
17 <script src=/resources/testharnessreport.js></script>
18 <script src=/resources/WebIDLParser.js></script>
19 <script src=/resources/idlharness.js></script>
20 <script>
21   "use strict";
22   idl_test(
23     ['mediacapture-main'],
24     ['dom', 'html'],
25     async idl_array => {
26       assert_true(undefined !== navigator.mediaDevices.enumerateDevices,
27         "navigator.mediaDevices.enumerateDevices exists");
28
29       const list = await navigator.mediaDevices.enumerateDevices();
30       if( list.length > 0 ) {
31         window._mediaInfo = list[0];
32         idl_array.add_objects({MediaDeviceInfo: ["_mediaInfo"]});
33       }
34
35       for(const media of list) {
36         if( media.kind == "audioinput" ||
37             media.kind == "videoinput") {
38           // TODO -- Check InputDeviceInfo IDL, getCapabilities()
39         } else if ( media.kind == "audiooutput" ) {
40           // TODO -- pass
41         } else {
42           assert_unreached("media.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.")
43         }
44       }
45     }
46   );
47 </script>
48 </body>
49 </html>