Commit 359138a0 authored by Jan-Ivar Bruaroey's avatar Jan-Ivar Bruaroey
Browse files

Bug 1876636 - Update WPT MediaStreamTrack-getSettings.https.html to verify...

Bug 1876636 - Update WPT MediaStreamTrack-getSettings.https.html to verify deviceId & groupId of initial gUM call. r=karlt

Differential Revision: https://phabricator.services.mozilla.com/D220945
parent 73c7fe8d
Loading
Loading
Loading
Loading
+23 −28
Original line number Diff line number Diff line
@@ -71,11 +71,25 @@
    const afterGum = await navigator.mediaDevices.getUserMedia({
      video: true, audio: true
    });
    afterGum.getTracks().forEach(track => track.stop());

    const devices = await navigator.mediaDevices.enumerateDevices();
    const inputDevices = devices.filter(({kind}) => kind != "audiooutput");
    assert_greater_than(inputDevices.length, 1, "have at least 2 test devices");

    // first check the default tracks from the already called getUserMedia()
    for (const track of afterGum.getTracks()) {
      const settings = track.getSettings();
      const device = inputDevices.find(({deviceId}) => deviceId == settings.deviceId);
      assert_not_equals(device, undefined, `track was from an enumerated device`);
      assert_equals(`${track.kind}input`, device.kind, `default track is the right kind.`);
      track.stop();
      assert_equals(typeof settings.deviceId, "string", "default deviceId is a string");
      assert_greater_than(settings.deviceId.length, 0, "default deviceId is not empty");
      assert_equals(settings.deviceId, device.deviceId, "default track deviceId matches device");
      assert_equals(typeof settings.groupId, "string", "default groupId is a string.");
      assert_greater_than(settings.groupId.length, 0, "default groupId is not empty");
      assert_equals(settings.groupId, device.groupId, "default track groupId matches device");
    }
    // then check explicitly requesting each input device
    for (const {kind, deviceId, groupId} of inputDevices) {
      const type = {videoinput: "video", audioinput: "audio"}[kind];
      const stream = await navigator.mediaDevices.getUserMedia({
@@ -84,22 +98,15 @@
      const [track] = stream.getTracks();
      const settings = track.getSettings();
      track.stop();
      assert_true(settings.groupId == groupId, "device groupId");
      assert_equals(`${track.kind}input`, kind, `track is of the right kind.`);
      assert_equals(typeof settings.deviceId, "string", "deviceId is a string.");
      assert_greater_than(settings.deviceId.length, 0, "deviceId is not empty");
      assert_equals(settings.deviceId, deviceId, "track and device deviceIds match");
      assert_equals(typeof settings.groupId, "string", "groupId is a string.");
      assert_greater_than(settings.groupId.length, 0, "groupId is not empty");
      assert_equals(settings.groupId, groupId, "track and device groupId match");
    }
  }, 'groupId is correctly reported by getSettings() for all input devices');

  promise_test(async t => {
    const settings = await createTrackAndGetSettings(t, "audio");
    assert_equals(typeof(settings.deviceId), "string",
                  "deviceId should exist and it should be a string.");
  }, 'deviceId is reported by getSettings() for getUserMedia() audio tracks');

  promise_test(async t => {
    const settings = await createTrackAndGetSettings(t, "audio");
    assert_equals(typeof(settings.groupId), "string",
                  "groupId should exist and it should be a string.");
  }, 'groupId is reported by getSettings() for getUserMedia() audio tracks');
  }, 'deviceId and groupId are correctly reported by getSettings() for all input devices');

  promise_test(async t => {
    const settings = await createTrackAndGetSettings(t, "audio");
@@ -153,18 +160,6 @@
    assert_greater_than(settings.channelCount, 0);
  }, 'channelCount is reported by getSettings() for getUserMedia() audio tracks');

  promise_test(async t => {
    const settings = await createTrackAndGetSettings(t, "video");
    assert_equals(typeof(settings.deviceId), "string",
                  "deviceId should exist and it should be a string.");
  }, 'deviceId is reported by getSettings() for getUserMedia() video tracks');

  promise_test(async t => {
    const settings = await createTrackAndGetSettings(t, "video");
    assert_equals(typeof(settings.groupId), "string",
                  "groupId should exist and it should be a string.");
  }, 'groupId is reported by getSettings() for getUserMedia() video tracks');

  promise_test(async t => {
    const settings = await createTrackAndGetSettings(t, "video");
    assert_equals(typeof(settings.width), "number",