Skip to content

Commit

Permalink
webrtc: update WPT for addIceCandidate(null)
Browse files Browse the repository at this point in the history
BUG=chromium:978582

Change-Id: I4f6e93bd900ad8f5caf55143ded48280a6b26475
  • Loading branch information
fippo authored and chromium-wpt-export-bot committed Feb 15, 2021
1 parent a8c6d1f commit 6181834
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 117 deletions.
18 changes: 2 additions & 16 deletions webrtc/RTCDtlsTransport-state.html
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
24 changes: 4 additions & 20 deletions webrtc/RTCPeerConnection-addIceCandidate-connectionSetup.html
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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') {
Expand Down
8 changes: 3 additions & 5 deletions webrtc/RTCPeerConnection-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ function exchangeIceCandidates(pc1, pc2) {
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);
}
});
Expand Down
8 changes: 2 additions & 6 deletions webrtc/RTCPeerConnection-iceConnectionState.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
};
Expand Down
18 changes: 2 additions & 16 deletions webrtc/RTCPeerConnection-restartIce.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 4 additions & 6 deletions webrtc/RTCRtpTransceiver.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
};
Expand Down
18 changes: 5 additions & 13 deletions webrtc/datachannel-emptystring.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,10 @@ <h2>Messages exchanged</h2>
}
});

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() {
Expand All @@ -81,8 +73,8 @@ <h2>Messages exchanged</h2>
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;

Expand Down
9 changes: 2 additions & 7 deletions webrtc/getstats.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,11 @@ <h2>Retrieved stats info</h2>
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) {
Expand Down
9 changes: 2 additions & 7 deletions webrtc/no-media-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,11 @@ <h2>iceConnectionState info</h2>
};

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) {
Expand Down
9 changes: 2 additions & 7 deletions webrtc/promises-call.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ <h2>iceConnectionState info</h2>
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) {
Expand Down
6 changes: 6 additions & 0 deletions webrtc/protocol/split.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});

Expand Down
9 changes: 2 additions & 7 deletions webrtc/simplecall-no-ssrcs.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 2 additions & 7 deletions webrtc/simplecall.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6181834

Please sign in to comment.