webrtc: update WPT for addIceCandidate(null) (#27605)
diff --git a/webrtc/RTCDtlsTransport-state.html b/webrtc/RTCDtlsTransport-state.html
index 33d4967..ca49fcc 100644
--- a/webrtc/RTCDtlsTransport-state.html
+++ b/webrtc/RTCDtlsTransport-state.html
@@ -93,22 +93,8 @@
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
- pc1.onicecandidate = e => {
- if (e.candidate) {
- pc2.addIceCandidate({
- candidate: e.candidate.candidate,
- sdpMid: e.candidate.sdpMid
- });
- }
- }
- pc2.onicecandidate = e => {
- if (e.candidate) {
- pc1.addIceCandidate({
- candidate: e.candidate.candidate,
- sdpMid: e.candidate.sdpMid
- });
- }
- }
+ pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
+ pc2.onicecandidate = e => pc1.addIceCandidate(e.candidate);
pc1.addTransceiver("video");
pc1.addTransceiver("audio");
diff --git a/webrtc/RTCPeerConnection-addIceCandidate-connectionSetup.html b/webrtc/RTCPeerConnection-addIceCandidate-connectionSetup.html
index 11fc4e4..d2cde59 100644
--- a/webrtc/RTCPeerConnection-addIceCandidate-connectionSetup.html
+++ b/webrtc/RTCPeerConnection-addIceCandidate-connectionSetup.html
@@ -35,16 +35,8 @@
let candidates1to2 = [];
let candidates2to1 = [];
- pc1.onicecandidate = event => {
- if (event.candidate) {
- candidates1to2.push(event.candidate);
- }
- }
- pc2.onicecandidate = event => {
- if (event.candidate) {
- candidates2to1.push(event.candidate);
- }
- }
+ pc1.onicecandidate = e => candidates1to2.push(e.candidate);
+ pc2.onicecandidate = e => candidates2to1.push(e.candidate);
const pc2GatheredCandidates = new Promise((resolve) => {
pc2.addEventListener('icegatheringstatechange', () => {
if (pc2.iceGatheringState == 'complete') {
@@ -74,16 +66,8 @@
let candidates1to2 = [];
let candidates2to1 = [];
- pc1.onicecandidate = event => {
- if (event.candidate) {
- candidates1to2.push(event.candidate);
- }
- }
- pc2.onicecandidate = event => {
- if (event.candidate) {
- candidates2to1.push(event.candidate);
- }
- }
+ pc1.onicecandidate = e => candidates1to2.push(e.candidate);
+ pc2.onicecandidate = e => candidates2to1.push(e.candidate);
const pc1GatheredCandidates = new Promise((resolve) => {
pc1.addEventListener('icegatheringstatechange', () => {
if (pc1.iceGatheringState == 'complete') {
diff --git a/webrtc/RTCPeerConnection-helper.js b/webrtc/RTCPeerConnection-helper.js
index cdfe63e..1521277 100644
--- a/webrtc/RTCPeerConnection-helper.js
+++ b/webrtc/RTCPeerConnection-helper.js
@@ -176,11 +176,9 @@
localPc.addEventListener('icecandidate', event => {
const { candidate } = event;
- // candidate may be null to indicate end of candidate gathering.
- // There is ongoing discussion on w3c/webrtc-pc#1213
- // that there should be an empty candidate string event
- // for end of candidate for each m= section.
- if(candidate && remotePc.signalingState !== 'closed') {
+ // Guard against already closed peerconnection to
+ // avoid unrelated exceptions.
+ if (remotePc.signalingState !== 'closed') {
remotePc.addIceCandidate(candidate);
}
});
diff --git a/webrtc/RTCPeerConnection-iceConnectionState.https.html b/webrtc/RTCPeerConnection-iceConnectionState.https.html
index 320b03d..5083be6 100644
--- a/webrtc/RTCPeerConnection-iceConnectionState.https.html
+++ b/webrtc/RTCPeerConnection-iceConnectionState.https.html
@@ -320,15 +320,11 @@
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc2.close());
- pc1.onicecandidate = async e => {
- if (e.candidate) {
- await pc2.addIceCandidate(e.candidate);
- }
- };
+ pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
pc1.candidateBuffer = [];
pc2.onicecandidate = e => {
// Don't add candidate if candidate buffer is already used
- if (e.candidate && pc1.candidateBuffer) {
+ if (pc1.candidateBuffer) {
pc1.candidateBuffer.push(e.candidate)
}
};
diff --git a/webrtc/RTCPeerConnection-restartIce.https.html b/webrtc/RTCPeerConnection-restartIce.https.html
index dc5e167..0e4ecf6 100644
--- a/webrtc/RTCPeerConnection-restartIce.https.html
+++ b/webrtc/RTCPeerConnection-restartIce.https.html
@@ -153,22 +153,8 @@
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
- pc1.onicecandidate = e => {
- if (e.candidate) {
- pc2.addIceCandidate({
- candidate: e.candidate.candidate,
- sdpMid: e.candidate.sdpMid
- });
- }
- }
- pc2.onicecandidate = e => {
- if (e.candidate) {
- pc1.addIceCandidate({
- candidate: e.candidate.candidate,
- sdpMid: e.candidate.sdpMid
- });
- }
- }
+ pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
+ pc2.onicecandidate = e => pc1.addIceCandidate(e.candidate);
// See the explanation below about Chrome's onnegotiationneeded firing
// too early.
diff --git a/webrtc/RTCRtpTransceiver.https.html b/webrtc/RTCRtpTransceiver.https.html
index c9dce45..77323b5 100644
--- a/webrtc/RTCRtpTransceiver.https.html
+++ b/webrtc/RTCRtpTransceiver.https.html
@@ -92,12 +92,10 @@
const trickle = (t, pc1, pc2) => {
pc1.onicecandidate = t.step_func(async e => {
- if (e.candidate) {
- try {
- await pc2.addIceCandidate(e.candidate);
- } catch (e) {
- assert_true(false, "addIceCandidate threw error: " + e.name);
- }
+ try {
+ await pc2.addIceCandidate(e.candidate);
+ } catch (e) {
+ assert_true(false, "addIceCandidate threw error: " + e.name);
}
});
};
diff --git a/webrtc/datachannel-emptystring.html b/webrtc/datachannel-emptystring.html
index 456bac7..a9741c1 100644
--- a/webrtc/datachannel-emptystring.html
+++ b/webrtc/datachannel-emptystring.html
@@ -60,18 +60,10 @@
}
});
- function exchangeIce(pc) {
- return function(e) {
- if (e.candidate) {
- pc.addIceCandidate(e.candidate);
- }
- };
- }
-
function exchangeDescription(pc1, pc2) {
- return function() {
- return pc1.setRemoteDescription(pc2.localDescription);
- };
+ return function() {
+ return pc1.setRemoteDescription(pc2.localDescription);
+ };
}
test.step(function() {
@@ -81,8 +73,8 @@
gSecondConnection = new RTCPeerConnection(null);
test.add_cleanup(() => gSecondConnection.close());
- gFirstConnection.onicecandidate = exchangeIce(gSecondConnection);
- gSecondConnection.onicecandidate = exchangeIce(gFirstConnection);
+ gFirstConnection.onicecandidate = e => gSecondConnection.addIceCandidate(e.candidate);
+ gSecondConnection.onicecandidate = e => gFirstConnection.addIceCandidate(e.candidate);
gSecondConnection.ondatachannel = onReceiveChannel;
diff --git a/webrtc/getstats.html b/webrtc/getstats.html
index 0950a37..d6a692b 100644
--- a/webrtc/getstats.html
+++ b/webrtc/getstats.html
@@ -27,16 +27,11 @@
var gSecondConnection = null;
var onIceCandidateToFirst = test.step_func(function(event) {
- // If event.candidate is null = no more candidates.
- if (event.candidate) {
- gSecondConnection.addIceCandidate(event.candidate);
- }
+ gSecondConnection.addIceCandidate(event.candidate);
});
var onIceCandidateToSecond = test.step_func(function(event) {
- if (event.candidate) {
- gFirstConnection.addIceCandidate(event.candidate);
- }
+ gFirstConnection.addIceCandidate(event.candidate);
});
var getStatsRecordByType = function(stats, type) {
diff --git a/webrtc/no-media-call.html b/webrtc/no-media-call.html
index b1eba08..9d25985 100644
--- a/webrtc/no-media-call.html
+++ b/webrtc/no-media-call.html
@@ -58,16 +58,11 @@
};
var onIceCandidateToFirst = test.step_func(function(event) {
- // If event.candidate is null = no more candidates.
- if (event.candidate) {
- gSecondConnection.addIceCandidate(event.candidate);
- }
+ gSecondConnection.addIceCandidate(event.candidate);
});
var onIceCandidateToSecond = test.step_func(function(event) {
- if (event.candidate) {
- gFirstConnection.addIceCandidate(event.candidate);
- }
+ gFirstConnection.addIceCandidate(event.candidate);
});
var onIceConnectionStateChange = test.step_func(function(event) {
diff --git a/webrtc/promises-call.html b/webrtc/promises-call.html
index 8b9a275..ee64b46 100644
--- a/webrtc/promises-call.html
+++ b/webrtc/promises-call.html
@@ -24,16 +24,11 @@
var gSecondConnection = null;
var onIceCandidateToFirst = test.step_func(function(event) {
- // If event.candidate is null = no more candidates.
- if (event.candidate) {
- gSecondConnection.addIceCandidate(event.candidate);
- }
+ gSecondConnection.addIceCandidate(event.candidate);
});
var onIceCandidateToSecond = test.step_func(function(event) {
- if (event.candidate) {
- gFirstConnection.addIceCandidate(event.candidate);
- }
+ gFirstConnection.addIceCandidate(event.candidate);
});
var onIceConnectionStateChange = test.step_func(function(event) {
diff --git a/webrtc/protocol/split.https.html b/webrtc/protocol/split.https.html
index 5eb8329..3fc3bda 100644
--- a/webrtc/protocol/split.https.html
+++ b/webrtc/protocol/split.https.html
@@ -38,16 +38,22 @@
if (e.candidate) {
const target = e.candidate.sdpMLineIndex === 0 ? calleeAudio : calleeVideo;
target.addIceCandidate({sdpMid: e.candidate.sdpMid, candidate: e.candidate.candidate});
+ } else {
+ calleeAudio.addIceCandidate();
+ calleeVideo.addIceCandidate();
}
});
calleeAudio.addEventListener('icecandidate', (e) => {
if (e.candidate) {
caller.addIceCandidate({sdpMid: e.candidate.sdpMid, candidate: e.candidate.candidate});
}
+ // Note: caller.addIceCandidate is only called for video to avoid calling it twice.
});
calleeVideo.addEventListener('icecandidate', (e) => {
if (e.candidate) {
caller.addIceCandidate({sdpMid: e.candidate.sdpMid, candidate: e.candidate.candidate});
+ } else {
+ caller.addIceCandidate();
}
});
diff --git a/webrtc/simplecall-no-ssrcs.https.html b/webrtc/simplecall-no-ssrcs.https.html
index 5160451..f2e2084 100644
--- a/webrtc/simplecall-no-ssrcs.https.html
+++ b/webrtc/simplecall-no-ssrcs.https.html
@@ -88,16 +88,11 @@
};
var onIceCandidateToFirst = test.step_func(function(event) {
- // If event.candidate is null = no more candidates.
- if (event.candidate) {
- gSecondConnection.addIceCandidate(event.candidate);
- }
+ gSecondConnection.addIceCandidate(event.candidate);
});
var onIceCandidateToSecond = test.step_func(function(event) {
- if (event.candidate) {
- gFirstConnection.addIceCandidate(event.candidate);
- }
+ gFirstConnection.addIceCandidate(event.candidate);
});
var onRemoteTrack = test.step_func(function(event) {
diff --git a/webrtc/simplecall.https.html b/webrtc/simplecall.https.html
index ffe043b..dbf6b9a 100644
--- a/webrtc/simplecall.https.html
+++ b/webrtc/simplecall.https.html
@@ -79,16 +79,11 @@
};
var onIceCandidateToFirst = test.step_func(function(event) {
- // If event.candidate is null = no more candidates.
- if (event.candidate) {
- gSecondConnection.addIceCandidate(event.candidate);
- }
+ gSecondConnection.addIceCandidate(event.candidate);
});
var onIceCandidateToSecond = test.step_func(function(event) {
- if (event.candidate) {
- gFirstConnection.addIceCandidate(event.candidate);
- }
+ gFirstConnection.addIceCandidate(event.candidate);
});
var onRemoteTrack = test.step_func(function(event) {