GUM-non-applicable-constraint.https.html (2963B)
1 <!doctype html> 2 <title>non-applicable constraint in getUserMedia</title> 3 <link rel="author" title="Intel" href="http://www.intel.com"/> 4 <link rel="help" href="https://w3c.github.io/mediacapture-main/#methods-5"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src=/resources/testdriver.js></script> 8 <script src=/resources/testdriver-vendor.js></script> 9 <script src=permission-helper.js></script> 10 11 <p class="instructions">When prompted, accept to share your audio and video stream.</p> 12 13 <script> 14 15 let video_only_valid_constraints = { 16 width: {min: 0}, 17 height: {min: 0}, 18 frameRate: {min: 0}, 19 aspectRatio: {min: 0}, 20 facingMode: {ideal: 'environment'}, 21 resizeMode: {ideal: 'none'} 22 } 23 24 let video_only_invalid_constraints = { 25 width: {min: 100000000}, 26 height: {min: 100000000}, 27 frameRate: {min: 100000000}, 28 aspectRatio: {min: 100000000}, 29 facingMode: {exact: 'invalid'}, 30 resizeMode: {exact: 'invalid'} 31 } 32 33 let audio_only_valid_constraints = { 34 volume: {min: 0}, 35 sampleRate: {min: 0}, 36 sampleSize: {min: 0}, 37 echoCancellation: {ideal: true}, 38 autoGainControl: {ideal: true}, 39 noiseSuppression: {ideal: true}, 40 voiceIsolation: {ideal: true}, 41 latency: {min: 0}, 42 channelCount: {min: 0} 43 } 44 45 let audio_only_invalid_constraints = { 46 volume: {min: 2}, 47 sampleRate: {min: 100000000}, 48 sampleSize: {min: 100000000}, 49 echoCancellation: {exact: true}, 50 autoGainControl: {exact: true}, 51 noiseSuppression: {exact: true}, 52 voiceIsolation: {exact: true}, 53 latency: {max: 0}, 54 channelCount: {max: 0} 55 } 56 57 promise_test(async () => { 58 // Both permissions are needed at some point, asking for both at once 59 await setMediaPermission(); 60 let stream = await navigator.mediaDevices.getUserMedia({audio: video_only_valid_constraints}) 61 assert_equals(stream.getAudioTracks().length, 1, "the media stream has exactly one audio track"); 62 }, 'Test that setting video-only valid constraints inside of "audio" is simply ignored'); 63 64 promise_test(async () => { 65 let stream = await navigator.mediaDevices.getUserMedia({audio: video_only_invalid_constraints}) 66 assert_equals(stream.getAudioTracks().length, 1, "the media stream has exactly one audio track"); 67 }, 'Test that setting video-only invalid constraints inside of "audio" is simply ignored'); 68 69 promise_test(async () => { 70 let stream = await navigator.mediaDevices.getUserMedia({video: audio_only_valid_constraints}) 71 assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track"); 72 }, 'Test that setting audio-only valid constraints inside of "video" is simply ignored'); 73 74 promise_test(async () => { 75 let stream = await navigator.mediaDevices.getUserMedia({video: audio_only_invalid_constraints}) 76 assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track"); 77 }, 'Test that setting audio-only invalid constraints inside of "video" is simply ignored'); 78 79 </script>