Bug 1555480 [wpt PR 17082] - Reland tests from "Change ICE connection state on transceiver changes", a=testonly

Automatic update from web-platform-tests
Reland tests from "Change ICE connection state on transceiver changes"

This reverts the rest of commit 2229f484784131f7c655c650b389cfd78fe3e739.

Reason for revert: Fixed the reason the test was flaky.

Original change's description:
> Revert "Change ICE connection state on transceiver changes"
>
> This reverts commit 0882bebe06b38aa5d4e155a5cebc11e7af08abd2.
>
> Reason for revert: Causing flaky failures of
> external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html
> on Linux Tests and WebKit Linux Trusty Leak
>
> https://ci.chromium.org/p/chromium/builders/ci/Linux%20Tests/78387
> https://ci.chromium.org/p/chromium/builders/ci/WebKit%20Linux%20Trusty%20Leak/34892
>
> Original change's description:
> > Change ICE connection state on transceiver changes
> >
> > This ensures that if the PC iceConnectionState should change
> > because unused transports are discarded, the state is updated.
> >
> > Bug: chromium:966798
> >
> > Change-Id: I09d945f5e70eec813f33c3131fbe889825613652
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1632254
> > Reviewed-by: Henrik Boström <hbos@chromium.org>
> > Commit-Queue: Harald Alvestrand <hta@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#664206}
>
> TBR=hta@chromium.org,hbos@chromium.org
>
> Change-Id: I2cbae9f1327e7aacb7022d2a823ce1e954c91b62
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:966798
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635208
> Reviewed-by: Aaron Gable <agable@chromium.org>
> Commit-Queue: Aaron Gable <agable@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#664388}

Bug: chromium:966798
Change-Id: I2e9887bc62942393a2d39042da9bfc85bbd98c91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636049
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668750}

--

wpt-commits: 8a474834dc86e8713b1f7e966d6d5aa8fd69c9a6
wpt-pr: 17082
This commit is contained in:
Harald Alvestrand 2019-07-19 12:23:23 +00:00 коммит произвёл James Graham
Родитель f4ba144438
Коммит 4302703dee
3 изменённых файлов: 153 добавлений и 2 удалений

Просмотреть файл

@ -254,6 +254,9 @@ async function doSignalingHandshake(localPc, remotePc, options={}) {
// This should work for RTCSctpTransport, RTCDtlsTransport and RTCIceTransport.
function waitForState(transport, state) {
return new Promise((resolve, reject) => {
if (transport.state == state) {
resolve();
}
const eventHandler = () => {
if (transport.state == state) {
transport.removeEventListener('statechange', eventHandler, false);

Просмотреть файл

@ -277,5 +277,42 @@ async_test(t => {
closed
The RTCIceTransport has shut down and is no longer responding to STUN requests.
*/
*/
for (let bundle_policy of ['balanced', 'max-bundle', 'max-compat']) {
promise_test(async t => {
const caller = new RTCPeerConnection({bundlePolicy: bundle_policy});
t.add_cleanup(() => caller.close());
const stream = await navigator.mediaDevices.getUserMedia(
{audio: true, video:true});
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
const [track1, track2] = stream.getTracks();
const sender1 = caller.addTrack(track1);
const sender2 = caller.addTrack(track2);
caller.createDataChannel('datachannel');
const callee = new RTCPeerConnection();
t.add_cleanup(() => callee.close());
coupleIceCandidates(caller, callee);
const offer = await caller.createOffer();
await caller.setLocalDescription(offer);
const [caller_transceiver1, caller_transceiver2] = caller.getTransceivers();
assert_equals(sender1.transport, caller_transceiver1.sender.transport);
await callee.setRemoteDescription(offer);
const [callee_transceiver1, callee_transceiver2] = callee.getTransceivers();
const answer = await callee.createAnswer();
await callee.setLocalDescription(answer);
await caller.setRemoteDescription(answer);
// At this point, we should have a single ICE transport, and it
// should eventually get to the "connected" state.
await waitForState(caller_transceiver1.receiver.transport.iceTransport,
'connected');
// The PeerConnection's iceConnectionState should therefore be 'connected'
assert_equals(caller.iceConnectionState, 'connected',
'PC.iceConnectionState:');
}, 'iceConnectionState changes at the right time, with bundle policy ' +
bundle_policy);
}
</script>

Просмотреть файл

@ -27,15 +27,36 @@ function iceGatheringCompleteWaiter(pc) {
return waiter;
}
class StateLogger {
constructor(source, eventname, field) {
source.addEventListener(eventname, event => {
this.events.push(source[field]);
});
this.events = [source[field]];
}
}
class IceStateLogger extends StateLogger {
constructor(source) {
super(source, 'iceconnectionstatechange', 'iceConnectionState');
}
}
promise_test(async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
pc1.createDataChannel('datachannel');
pc1IceStates = new IceStateLogger(pc1);
pc2IceStates = new IceStateLogger(pc1);
coupleIceCandidates(pc1, pc2);
await doSignalingHandshake(pc1, pc2);
await waitForIceStateChange(pc1, ['connected', 'completed']);
// Note - it's been claimed that this state sometimes jumps straight
// to "completed". If so, this test should be flaky.
await waitForIceStateChange(pc1, ['connected']);
assert_array_equals(pc1IceStates.events, ['new', 'checking', 'connected']);
assert_array_equals(pc2IceStates.events, ['new', 'checking', 'connected']);
}, 'Two way ICE exchange works');
promise_test(async t => {
@ -43,6 +64,8 @@ promise_test(async t => {
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
pc1IceStates = new IceStateLogger(pc1);
pc2IceStates = new IceStateLogger(pc1);
let candidates = [];
pc1.createDataChannel('datachannel');
pc1.onicecandidate = e => {
@ -63,6 +86,8 @@ promise_test(async t => {
const candidate_pair = pc1.sctp.transport.iceTransport.getSelectedCandidatePair();
assert_equals(candidate_pair.local.type, 'host');
assert_equals(candidate_pair.remote.type, 'prflx');
assert_array_equals(pc1IceStates.events, ['new', 'checking', 'connected']);
assert_array_equals(pc2IceStates.events, ['new', 'checking', 'connected']);
}, 'Adding only caller -> callee candidates gives a connection');
promise_test(async t => {
@ -70,6 +95,8 @@ promise_test(async t => {
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
pc1IceStates = new IceStateLogger(pc1);
pc2IceStates = new IceStateLogger(pc1);
let candidates = [];
pc1.createDataChannel('datachannel');
pc2.onicecandidate = e => {
@ -90,8 +117,92 @@ promise_test(async t => {
const candidate_pair = pc2.sctp.transport.iceTransport.getSelectedCandidatePair();
assert_equals(candidate_pair.local.type, 'host');
assert_equals(candidate_pair.remote.type, 'prflx');
assert_array_equals(pc1IceStates.events, ['new', 'checking', 'connected']);
assert_array_equals(pc2IceStates.events, ['new', 'checking', 'connected']);
}, 'Adding only callee -> caller candidates gives a connection');
promise_test(async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
pc1IceStates = new IceStateLogger(pc1);
pc2IceStates = new IceStateLogger(pc1);
let pc2ToPc1Candidates = [];
pc1.createDataChannel('datachannel');
pc2.onicecandidate = e => {
pc2ToPc1Candidates.push(e.candidate);
// This particular test verifies that candidates work
// properly if added from the pc2 onicecandidate event.
if (!e.candidate) {
for (const candidate of pc2ToPc1Candidates) {
if (candidate) {
pc1.addIceCandidate(candidate);
}
}
}
}
// Candidates from |pc1| are not delivered to |pc2|. |pc2| will use
// peer-reflexive candidates.
await doSignalingHandshake(pc1, pc2);
await Promise.all([waitForIceStateChange(pc1, ['connected', 'completed']),
waitForIceStateChange(pc2, ['connected', 'completed'])]);
const candidate_pair = pc2.sctp.transport.iceTransport.getSelectedCandidatePair();
assert_equals(candidate_pair.local.type, 'host');
assert_equals(candidate_pair.remote.type, 'prflx');
assert_array_equals(pc1IceStates.events, ['new', 'checking', 'connected']);
assert_array_equals(pc2IceStates.events, ['new', 'checking', 'connected']);
}, 'Adding callee -> caller candidates from end-of-candidates gives a connection');
promise_test(async t => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
pc1IceStates = new IceStateLogger(pc1);
pc2IceStates = new IceStateLogger(pc1);
let pc1ToPc2Candidates = [];
let pc2ToPc1Candidates = [];
pc1.createDataChannel('datachannel');
pc1.onicecandidate = e => {
pc1ToPc2Candidates.push(e.candidate);
}
pc2.onicecandidate = e => {
pc2ToPc1Candidates.push(e.candidate);
}
const offer = await pc1.createOffer();
await Promise.all([pc1.setLocalDescription(offer),
pc2.setRemoteDescription(offer)]);
const answer = await pc2.createAnswer();
await iceGatheringCompleteWaiter(pc1);
await pc2.setLocalDescription(answer).then(() => {
for (const candidate of pc1ToPc2Candidates) {
if (candidate) {
pc2.addIceCandidate(candidate);
}
}
});
await iceGatheringCompleteWaiter(pc2);
pc1.setRemoteDescription(answer).then(async () => {
for (const candidate of pc2ToPc1Candidates) {
if (candidate) {
await pc1.addIceCandidate(candidate);
}
}
});
await Promise.all([waitForIceStateChange(pc1, ['connected', 'completed']),
waitForIceStateChange(pc2, ['connected', 'completed'])]);
const candidate_pair =
pc1.sctp.transport.iceTransport.getSelectedCandidatePair();
assert_equals(candidate_pair.local.type, 'host');
// When we supply remote candidates, we expect a jump to the 'host' candidate,
// but it might also remain as 'prflx'.
assert_true(candidate_pair.remote.type == 'host' ||
candidate_pair.remote.type == 'prflx');
assert_array_equals(pc1IceStates.events, ['new', 'checking', 'connected']);
assert_array_equals(pc2IceStates.events, ['new', 'checking', 'connected']);
}, 'Explicit offer/answer exchange gives a connection');
</script>
</body>
</html>