[mediacapture-screen-share] Behavior for getDisplayMedia() and getDisplayMedia({}) should be the same

foolip has just created a new issue for https://github.com/w3c/mediacapture-screen-share:

== Behavior for getDisplayMedia() and getDisplayMedia({}) should be the same ==
https://w3c.github.io/mediacapture-screen-share/#navigator-additions says:

> If the constraints argument is omitted, a default value containing a single video attribute set to true is assumed.

However, this doesn't match the `MediaStreamConstraints` definition in https://w3c.github.io/mediacapture-main/#mediastreamconstraints:
```webidl
dictionary MediaStreamConstraints {
             (boolean or MediaTrackConstraints) video = false;
             (boolean or MediaTrackConstraints) audio = false;
};
```

Here, `video` has a default value of false. Web IDL says in https://heycam.github.io/webidl/#dfn-optional-argument-default-value:
> If the type of an argument is a dictionary type or a union type that has a dictionary as one of its flattened member types, and that dictionary type and its ancestors have no required members, and the argument is either the final argument or is followed only by optional arguments, then the argument must be specified as optional. Such arguments are always considered to have a default value of an empty dictionary, unless otherwise specified.

In other words, per Web IDL, in this case, `constraints` is considered to have a default value of `{}`, which means that `getDisplayMedia()` and `getDisplayMedia({})` will be indistinguishable. `getDisplayMedia({ audio: false })` should also have the same behavior if `audio` has a default value of `false`, which it does here.

The most straightforward fix for this would be to make the IDL match the wanted behavior, e.g.:
```webidl
dictionary DisplayMediaConstraints {
             boolean video = true;
             boolean audio = false;
};
```

As a very unfortunate side effect `getDisplayMedia({ video: false })` and `getDisplayMedia({ video: undefined })` will not mean the same thing even though `undefined` is a falsy value, but I don't see another great solution.

Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/65 using your GitHub account

Received on Monday, 20 August 2018 10:05:58 UTC