Bug 1562570 - Assert that constraints are supported before trying to use them. r=jib
authorAndreas Pehrson <apehrson@mozilla.com>
Mon, 01 Jul 2019 17:18:13 +0000
changeset 540471 edf90d04cbcd51e56b3de6289c7f285760aba745
parent 540470 e100aae6c49feaab2a2af49d2cd7ed83a438835a
child 540472 33162c24b64fc0f2e58f7d2394589854cec35287
push id11529
push userarchaeopteryx@coole-files.de
push dateThu, 04 Jul 2019 15:22:33 +0000
treeherdermozilla-beta@ebb510a784b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1562570
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562570 - Assert that constraints are supported before trying to use them. r=jib Differential Revision: https://phabricator.services.mozilla.com/D36459
testing/web-platform/tests/mediacapture-streams/MediaDevices-getUserMedia.https.html
--- a/testing/web-platform/tests/mediacapture-streams/MediaDevices-getUserMedia.https.html
+++ b/testing/web-platform/tests/mediacapture-streams/MediaDevices-getUserMedia.https.html
@@ -33,16 +33,18 @@ test(function () {
   //   list.echoCancellation
   //   list.latency
   //   list.channelCount
   //   list.deviceId
   //   list.groupId
   }, "mediaDevices.getUserMedia() is present on navigator");
 
 promise_test(async t => {
+  assert_true(navigator.mediaDevices.getSupportedConstraints()["groupId"],
+    "groupId should be supported");
   const devices = await navigator.mediaDevices.enumerateDevices();
   for (const device of devices) {
     await navigator.mediaDevices.getUserMedia(
         {video: {groupId: {exact: device.groupId}}}).then(stream => {
       const found_device = devices.find(({deviceId}) =>
         deviceId == stream.getTracks()[0].getSettings().deviceId);
       assert_not_equals(found_device, undefined);
       assert_equals(found_device.kind, "videoinput");
@@ -53,16 +55,18 @@ promise_test(async t => {
       const found_device = devices.find(element =>
         element.kind == "videoinput" && element.groupId == device.groupId);
       assert_equals(found_device, undefined);
     });
   }
 }, 'groupId is correctly supported by getUserMedia() for video devices');
 
 promise_test(async t => {
+  assert_true(navigator.mediaDevices.getSupportedConstraints()["groupId"],
+    "groupId should be supported");
   const devices = await navigator.mediaDevices.enumerateDevices();
   for (const device of devices) {
     await navigator.mediaDevices.getUserMedia(
         {audio: {groupId: {exact: device.groupId}}}).then(stream => {
       const found_device = devices.find(({deviceId}) =>
         deviceId == stream.getTracks()[0].getSettings().deviceId);
       assert_not_equals(found_device, undefined);
       assert_equals(found_device.kind, "audioinput");
@@ -73,32 +77,38 @@ promise_test(async t => {
       const found_device = devices.find(element =>
         element.kind == "audioinput" && element.groupId == device.groupId);
       assert_equals(found_device, undefined);
     });
   }
 }, 'groupId is correctly supported by getUserMedia() for audio devices');
 
 promise_test(async t => {
+  assert_true(navigator.mediaDevices.getSupportedConstraints()["resizeMode"],
+    "resizeMode should be supported");
   const stream = await navigator.mediaDevices.getUserMedia(
       { video: {resizeMode: {exact: 'none'}}});
   const [track] = stream.getVideoTracks();
   t.add_cleanup(() => track.stop());
   assert_equals(track.getSettings().resizeMode, 'none');
 }, 'getUserMedia() supports setting none as resizeMode.');
 
 promise_test(async t => {
+  assert_true(navigator.mediaDevices.getSupportedConstraints()["resizeMode"],
+    "resizeMode should be supported");
   const stream = await navigator.mediaDevices.getUserMedia(
       { video: {resizeMode: {exact: 'crop-and-scale'}}});
   const [track] = stream.getVideoTracks();
   t.add_cleanup(() => track.stop());
   assert_equals(track.getSettings().resizeMode, 'crop-and-scale');
 }, 'getUserMedia() supports setting crop-and-scale as resizeMode.');
 
 promise_test(async t => {
+  assert_true(navigator.mediaDevices.getSupportedConstraints()["resizeMode"],
+    "resizeMode should be supported");
   try {
     const stream = await navigator.mediaDevices.getUserMedia(
         { video: {resizeMode: {exact: 'INVALID'}}});
     t.add_cleanup(() => stream.getVideoTracks()[0].stop());
     t.unreached_func('getUserMedia() should fail with invalid resizeMode')();
   } catch (e) {
     assert_equals(e.name, 'OverconstrainedError');
     assert_equals(e.constraint, 'resizeMode');