Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / mediastream / getusermedia-promise.html
blob044e793efb12f06b3966e5694c12cde0043f610a
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 </head>
7 <body>
8 <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);
16 });
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})
24 .then(function(s) {
25 assert_equals(s.getTracks().length, 2);
26 assert_equals(s.getAudioTracks().length, 1);
27 assert_equals(s.getVideoTracks().length, 1);
28 });
29 }, 'getUserMedia() audio and video tracks');
31 promise_test(function() {
32 return navigator.mediaDevices.getUserMedia(
33 {audio: {'mandatory': { 'valid_but_unsupported_1': 0}}})
34 .then(function(s) {
35 fail('getUserMedia should have failed');
36 }).catch(function(e) {
37 assert_equals(e.name, 'ConstraintNotSatisfiedError');
38 });
39 }, 'getUserMedia() with unsupported mandatory constraint');
42 </script>
43 </body>
44 </html>