gecko-dev/testing/web-platform/tests/webrtc/RTCIceTransport-extension-helper.js
Steve Anton ab197ce01d Bug 1487585 [wpt PR 12771] - RTCQuicTransport: start() implementation, a=testonly
Automatic update from web-platform-testsRTCQuicTransport: start() implementation

This change implements the RTCQuicTransport.start() method and
associated events: onstatechange, onerror.

Bug: 874296
Change-Id: I8cb5d525ff5dd9d7d0a07a306f72297febc9aaaa
Reviewed-on: https://chromium-review.googlesource.com/1171904
Commit-Queue: Steve Anton <steveanton@chromium.org>
Reviewed-by: Henrik Boström <hbos@chromium.org>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595191}

--

wpt-commits: 1931a2758eef0ba57f7f3f6608baf0082a4e1bb3
wpt-pr: 12771
2018-10-08 16:45:32 +00:00

42 lines
1.5 KiB
JavaScript

'use strict';
// Construct an RTCIceTransport instance. The instance will automatically be
// cleaned up when the test finishes.
function makeIceTransport(t) {
const iceTransport = new RTCIceTransport();
t.add_cleanup(() => iceTransport.stop());
return iceTransport;
}
// Construct two RTCIceTransport instances, configure them to exchange
// candidates, then gather() them.
// Returns a 2-list: [ RTCIceTransport, RTCIceTransport ]
function makeAndGatherTwoIceTransports(t) {
const localTransport = makeIceTransport(t);
const remoteTransport = makeIceTransport(t);
localTransport.onicecandidate = e => {
if (e.candidate) {
remoteTransport.addRemoteCandidate(e.candidate);
}
};
remoteTransport.onicecandidate = e => {
if (e.candidate) {
localTransport.addRemoteCandidate(e.candidate);
}
};
localTransport.gather({});
remoteTransport.gather({});
return [ localTransport, remoteTransport ];
}
// Construct two RTCIceTransport instances, configure them to exchange
// candidates and parameters, then gather() and start() them.
// Returns a 2-list:
// [ controlling RTCIceTransport,
// controlled RTCIceTransport ]
function makeGatherAndStartTwoIceTransports(t) {
const [ localTransport, remoteTransport ] = makeAndGatherTwoIceTransports(t);
localTransport.start(remoteTransport.getLocalParameters(), 'controlling');
remoteTransport.start(localTransport.getLocalParameters(), 'controlled');
return [ localTransport, remoteTransport ];
}