OLD | NEW |
| (Empty) |
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="https://w3c.github.io/mediacapture-main/#enumerating-devi
ces"> | |
7 <meta name='assert' content='Check that the enumerateDevices() method is present
.'/> | |
8 </head> | |
9 <body> | |
10 <h1 class="instructions">Description</h1> | |
11 <p class="instructions">This test checks for the presence of the | |
12 <code>navigator.mediaDevices.enumerateDevices()</code> method.</p> | |
13 <div id='log'></div> | |
14 <script src=/resources/testharness.js></script> | |
15 <script src=/resources/testharnessreport.js></script> | |
16 <script> | |
17 "use strict"; | |
18 //NOTE ALEX: for completion, a test for ondevicechange event is missing. | |
19 test(function () { | |
20 assert_true(undefined !== navigator.mediaDevices.enumerateDevices, "navigator.
mediaDevices.enumerateDevices exists"); | |
21 var p = navigator.mediaDevices.enumerateDevices() | |
22 p.then(function(list){ | |
23 for(let mediainfo of list){ | |
24 // TODO check the type of mediainfo | |
25 assert_true(undefined !== mediainfo.deviceId, "mediaInfo's deviceId should
exist."); | |
26 assert_true(undefined !== mediainfo.kind, "mediaInfo's kind should
exist."); | |
27 assert_true(undefined !== mediainfo.label, "mediaInfo's label should
exist."); | |
28 assert_true(undefined !== mediainfo.groupId, "mediaInfo's groupId should
exist."); | |
29 // TODO the values of some of those fields should be empty string by defau
lt if no permission has been requested. | |
30 if( mediainfo.kind == "audioinput" || | |
31 mediainfo.kind == "videoinput") { | |
32 // NOTE ALEX: looks like nobody has implemented that. How can I make it
a separate test, | |
33 // ... to have better granularity? | |
34 // assert_true(undefined !== mediainfo.getCapabilities(), "MediaDeviceIn
fo.getCapabilities() exists."); | |
35 // var cap = mediainfo.getcapabilities(); | |
36 } else if ( mediainfo.kind !== "audiooutput" ) { | |
37 assert_unreached("mediainfo.kind should be one of 'audioinput', 'videoin
put', or 'audiooutput'.") | |
38 } | |
39 } | |
40 }) | |
41 p.catch(function(err){ | |
42 assert_unreached("A call to enumerateDevices() should never fail."); | |
43 }); | |
44 }, "mediaDevices.enumerateDevices() is present and working on navigator"); | |
45 </script> | |
46 </body> | |
47 </html> | |
OLD | NEW |