summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBasilisk-Dev <basiliskdev@protonmail.com>2023-10-09 17:04:07 -0400
committerBasilisk-Dev <basiliskdev@protonmail.com>2023-10-09 17:04:07 -0400
commit81cf4413e21bcda21aa6664d53c2ab74dd749b37 (patch)
tree9be06d1c34215b9766a3e09e6bd5f77a2dd74586
parent09e6d13d6b2fd2851ea8076efb72f219cd65c2cd (diff)
downloaduxp-81cf4413e21bcda21aa6664d53c2ab74dd749b37.tar.gz
Issue #2332 - Have addIceCandidate take a dictionary
Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=1263312 part 2
-rw-r--r--dom/media/PeerConnection.js11
-rw-r--r--dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html29
-rw-r--r--dom/webidl/RTCPeerConnection.webidl2
3 files changed, 24 insertions, 18 deletions
diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js
index 991cf5798f..712c2b0d13 100644
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -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;
diff --git a/dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html b/dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html
index 93cbdd0832..a46af2d2f0 100644
--- a/dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html
+++ b/dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html
@@ -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();
diff --git a/dom/webidl/RTCPeerConnection.webidl b/dom/webidl/RTCPeerConnection.webidl
index b852d32070..272d9c6c4e 100644
--- a/dom/webidl/RTCPeerConnection.webidl
+++ b/dom/webidl/RTCPeerConnection.webidl
@@ -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;