Issue #2332 - Have addIceCandidate take a dictionary

Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=1263312 part 2
This commit is contained in:
Basilisk-Dev 2023-10-09 17:04:07 -04:00 committed by roytam1
commit 80a3c49ba2
3 changed files with 24 additions and 18 deletions

View file

@ -985,12 +985,15 @@ RTCPeerConnection.prototype = {
containsTrickle(topSection) || sections.every(containsTrickle);
},
addIceCandidate: function(c, onSuccess, onError) {
return this._legacyCatchAndCloseGuard(onSuccess, onError, () => {
if (!c.candidate && !c.sdpMLineIndex) {
throw new this._win.DOMException("Invalid candidate passed to addIceCandidate!",
"InvalidParameterError");
if (!c) {
// TODO: Implement processing for end-of-candidates (bug 1318167)
return Promise.resolve();
}
if (c.sdpMid === null && c.sdpMLineIndex === null) {
throw new this._win.DOMException("Invalid candidate (both sdpMid and sdpMLineIndex are null).",
"TypeError");
}
return this._chain(() => new this._win.Promise((resolve, reject) => {
this._onAddIceCandidateSuccess = resolve;

View file

@ -54,15 +54,15 @@
}
);
},
function PC_REMOTE_ADD_CANDIDATE_MISSING_INDEX(test) {
// Note: it is probably not a good idea to automatically fill a missing
// MLineIndex with a default value of zero, see bug 1157034
function PC_REMOTE_ADD_MISSING_MID_AND_MISSING_INDEX(test) {
var broken = new RTCIceCandidate(
{candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host"});
return test.pcRemote._pc.addIceCandidate(broken)
.then(
// FIXME this needs to be updated once bug 1157034 is fixed
todo(false, "Missing index in got automatically set to a valid value bz://1157034")
generateErrorCallback("addIceCandidate should have failed."),
err => {
is(err.name, "TypeError", "Error is TypeError");
}
);
},
function PC_REMOTE_ADD_VALID_CANDIDATE(test) {
@ -70,7 +70,7 @@
{candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host",
sdpMLineIndex: 0});
return test.pcRemote._pc.addIceCandidate(candidate)
.then(ok(true, "Successfully added valid ICE candidate"));
.then(() => ok(true, "Successfully added valid ICE candidate"));
},
// bug 1095793
function PC_REMOTE_ADD_MISMATCHED_MID_AND_LEVEL_CANDIDATE(test) {
@ -79,12 +79,15 @@
sdpMLineIndex: 0,
sdpMid: "sdparta_1"});
return test.pcRemote._pc.addIceCandidate(bogus)
.then(
generateErrorCallback("addIceCandidate should have failed."),
err => {
is(err.name, "InvalidCandidateError", "Error is InvalidCandidateError");
}
);
.then(generateErrorCallback("addIceCandidate should have failed."),
err => is(err.name, "InvalidCandidateError", "Error is InvalidCandidateError"));
},
function PC_REMOTE_ADD_MID_AND_MISSING_INDEX(test) {
var candidate = new RTCIceCandidate(
{candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host",
sdpMid: "sdparta_0"});
return test.pcRemote._pc.addIceCandidate(candidate)
.then(() => ok(true, "Successfully added valid ICE candidate"));
},
function PC_REMOTE_ADD_MATCHING_MID_AND_LEVEL_CANDIDATE(test) {
var candidate = new mozRTCIceCandidate(
@ -92,7 +95,7 @@
sdpMLineIndex: 0,
sdpMid: "sdparta_0"});
return test.pcRemote._pc.addIceCandidate(candidate)
.then(ok(true, "Successfully added valid ICE candidate with matching mid and level"));
.then(() => ok(true, "Successfully added valid ICE candidate with matching mid and level"));
}
]);
test.run();

View file

@ -91,7 +91,7 @@ interface RTCPeerConnection : EventTarget {
readonly attribute RTCSessionDescription? localDescription;
readonly attribute RTCSessionDescription? remoteDescription;
readonly attribute RTCSignalingState signalingState;
Promise<void> addIceCandidate (RTCIceCandidate candidate);
Promise<void> addIceCandidate ((RTCIceCandidateInit or RTCIceCandidate)? candidate);
readonly attribute boolean? canTrickleIceCandidates;
readonly attribute RTCIceGatheringState iceGatheringState;
readonly attribute RTCIceConnectionState iceConnectionState;