Re: [webrtc-pc] RTCSessionDescriptionInit vs "local" RTCLocalSessionDescriptionInit (#2940)

[RTCSessionDescriptionInit](https://w3c.github.io/webrtc-pc/#idl-def-rtcsessiondescriptioninit) differs from RTCLocalSessionDescriptionInit by its `type` member being [required](https://webidl.spec.whatwg.org/#required-dictionary-member):
```js
dictionary RTCSessionDescriptionInit {
  required RTCSdpType type;
  DOMString sdp = "";
};
```
vs.
```js
dictionary RTCLocalSessionDescriptionInit {
  RTCSdpType type;
  DOMString sdp = "";
};
```

This is what allows `description` to be optional in sLD but not in sRD:
```js
  Promise<undefined> setLocalDescription(optional RTCLocalSessionDescriptionInit description = {});
  Promise<undefined> setRemoteDescription(RTCSessionDescriptionInit description);
```
...which is observable:
```js
pc.setLocalDescription(); // fine
pc.setLocalDescription({type: "rollback"}); // fine
pc.setRemoteDescription({type: "rollback"}); // also fine
pc.setRemoteDescription(); // TypeError

RTCPeerConnection.prototype.setLocalDescription.length // 0
RTCPeerConnection.prototype.setRemoteDescription.length // 1
```
So this is by design.

> Problem: [Dart Language web bindings ](https://github.com/dart-lang/web/)which are generated from IDL is having an https://github.com/dart-lang/web/issues/178 where RTCLocalSessionDescriptionInit and RTCSessionDescriptionInit are unique, and neither class implements the other. This seems inconsistent with MDN and actual usage.

WebIDL [dictionaries](https://webidl.spec.whatwg.org/#idl-dictionaries) are not classes or interfaces: _"an operation that accepts a dictionary as an argument will perform a one-time conversion from the given JavaScript value into the dictionary, based on the current properties of the JavaScript object"_

IOW member-compatible inputs are valid, making RTCSessionDescriptionInit valid input to a method expecting RTCLocalSessionDescriptionInit.

If the Dart Language web bindings cannot express this then that seems like a limitation of those bindings.

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2940#issuecomment-1965488897 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 26 February 2024 23:06:07 UTC