GUM-required-constraint-with-ideal-value.https.html (1516B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>Ideal value in required constraint in getUserMedia</title> 5 <link rel="author" title="Intel" href="http://www.intel.com"/> 6 <link rel="help" href="https://w3c.github.io/mediacapture-main/#dfn-fitness-distance"> 7 <script src=/resources/testharness.js></script> 8 <script src=/resources/testharnessreport.js></script> 9 <script src=/resources/testdriver.js></script> 10 <script src=/resources/testdriver-vendor.js></script> 11 <script src=permission-helper.js></script> 12 </head> 13 <body> 14 <p class="instructions">When prompted, accept to share your video stream.</p> 15 <h1 class="instructions">Description</h1> 16 <p class="instructions">This test checks that setting a required constraint 17 with an ideal value in getUserMedia works</p> 18 <div id='log'></div> 19 <script> 20 promise_test(async t => { 21 await setMediaPermission("granted", ["camera"]); 22 const stream = await navigator.mediaDevices.getUserMedia({video: {width: {ideal: 320, min: 160}}}); 23 assert_equals(stream.getVideoTracks().length, 1, "the media stream has exactly one video track"); 24 assert_equals(stream.getVideoTracks()[0].getSettings().width, 320, 'ideal width is selected for getUserMedia() video tracks'); 25 const video = document.createElement('video'); 26 video.srcObject = stream; 27 await video.play(); 28 assert_equals(video.videoWidth, 320, 'video width equals to track width'); 29 stream.getVideoTracks()[0].stop(); 30 }, "Tests that setting a required constraint with an ideal value in getUserMedia works"); 31 </script> 32 </body> 33 </html>