RTCPeerConnection: Write tests for #setLocalDescription
Working under branch set-local-description
FYI, I had setLocalDescription working on https://github.com/aisouard/node-webrtc/pull/5.
I can understand that you want to start clean though ;)
I really prefer to make sure that the tests are working according to the spec, your work is helpful for the events, I'm getting stuck right now because the onsignalingstatechange gets reset to null (on my side), not sure why, I'll find out this week.
The new specs looks like bad news by the way:
Promise<void> setLocalDescription(RTCSessionDescriptionInit description,
VoidFunction successCallback,
RTCPeerConnectionErrorCallback failureCallback);
Run the steps specified by RTCPeerConnection 's setLocalDescription method with
description as the sole argument, and let p be the resulting promise.
Upon fulfillment of p, invoke successCallback with undefined as the argument.
Upon rejection of p with reason r, invoke failureCallback with r as the argument.
Return a promise resolved with undefined.
Callbacks arguments are mandatory. Why should I return a promise and set a callback at the same time ? Does it destroy the purpose of promises ? Or is it just for backward-compatibility, since callbacks were removed inside the November 2016 spec ?
It's a bit weird, but I think it somehow makes sense:
- callbacks are mandatory to enforce definition of at least one success / error behaviour (which is difficult to do with promises)
- a promise is returned in all cases, which is always better than returning
null(and maybe to comply to this spec). The user still has the choice to drop it if he doesn't need it.
I think this implies that the callbacks must be handled using the promise internally, in order to avoid Uncaught error (in promise) if the promise is not used / if no .catch is defined.