4 <script src=
"../../resources/testharness.js"></script>
5 <script src=
"../../resources/testharnessreport.js"></script>
10 promise_test(function() {
11 assert_idl_attribute(navigator
, 'mediaDevices');
12 assert_idl_attribute(navigator
.mediaDevices
, 'getUserMedia');
14 return navigator
.mediaDevices
.getUserMedia({audio
: true}).then(function(s
) {
15 assert_equals(s
.getTracks().length
, 1);
17 }, 'getUserMedia() audio track');
19 promise_test(function() {
20 assert_idl_attribute(navigator
, 'mediaDevices');
21 assert_idl_attribute(navigator
.mediaDevices
, 'getUserMedia');
23 return navigator
.mediaDevices
.getUserMedia({audio
: true, video
:true})
25 assert_equals(s
.getTracks().length
, 2);
26 assert_equals(s
.getAudioTracks().length
, 1);
27 assert_equals(s
.getVideoTracks().length
, 1);
29 }, 'getUserMedia() audio and video tracks');
31 promise_test(function() {
32 return navigator
.mediaDevices
.getUserMedia(
33 {audio
: {'mandatory': { 'valid_but_unsupported_1': 0}}})
35 fail('getUserMedia should have failed');
36 }).catch(function(e
) {
37 assert_equals(e
.name
, 'ConstraintNotSatisfiedError');
39 }, 'getUserMedia() with unsupported mandatory constraint');