Update web-platform-tests to revision 122a4672fa0dc554a6e7528fa3487fd907c792ee

This commit is contained in:
WPT Sync Bot 2019-03-23 21:54:52 -04:00
parent fb1123495f
commit 93d826f7ba
301 changed files with 4775 additions and 1769 deletions

View file

@ -261,51 +261,93 @@ function listenForSSRCs(t, receiver) {
// end points to open.
function createDataChannelPair(
pc1=new RTCPeerConnection(),
pc2=new RTCPeerConnection())
pc2=new RTCPeerConnection(),
options={})
{
const channel1 = pc1.createDataChannel('');
options = Object.assign({}, {
channelLabel: '',
channelOptions: undefined,
doSignaling: true
}, options);
exchangeIceCandidates(pc1, pc2);
let channel1Options;
let channel2Options = null;
if (options.channelOptions instanceof Array) {
[channel1Options, channel2Options] = options.channelOptions;
} else {
channel1Options = options.channelOptions;
}
const channel1 = pc1.createDataChannel(options.channelLabel, channel1Options);
return new Promise((resolve, reject) => {
let channel2;
let opened1 = false;
let opened2 = false;
function cleanup() {
channel1.removeEventListener('open', onOpen1);
channel2.removeEventListener('open', onOpen2);
channel1.removeEventListener('error', onError);
channel2.removeEventListener('error', onError);
}
function onBothOpened() {
cleanup();
resolve([channel1, channel2]);
}
function onError(...args) {
cleanup();
reject(...args);
}
function onOpen1() {
opened1 = true;
if(opened2) onBothOpened();
if (opened2) {
onBothOpened();
}
}
function onOpen2() {
opened2 = true;
if(opened1) onBothOpened();
if (opened1) {
onBothOpened();
}
}
function onDataChannelPairFound() {
channel2.addEventListener('error', onError, { once: true });
const { readyState } = channel2;
if (readyState === 'open') {
onOpen2();
} else if (readyState === 'connecting') {
channel2.addEventListener('open', onOpen2, { once: true });
} else {
onError(new Error(`Unexpected ready state ${readyState}`));
}
}
function onDataChannel(event) {
channel2 = event.channel;
channel2.addEventListener('error', reject);
const { readyState } = channel2;
if(readyState === 'open') {
onOpen2();
} else if(readyState === 'connecting') {
channel2.addEventListener('open', onOpen2);
} else {
reject(new Error(`Unexpected ready state ${readyState}`));
}
onDataChannelPairFound();
}
channel1.addEventListener('open', onOpen1);
channel1.addEventListener('error', reject);
channel1.addEventListener('open', onOpen1, { once: true });
channel1.addEventListener('error', onError, { once: true });
pc2.addEventListener('datachannel', onDataChannel);
if (channel2Options !== null) {
channel2 = pc2.createDataChannel(options.channelLabel, channel2Options);
onDataChannelPairFound();
} else {
pc2.addEventListener('datachannel', onDataChannel);
}
doSignalingHandshake(pc1, pc2);
if (options.doSignaling) {
exchangeIceCandidates(pc1, pc2);
doSignalingHandshake(pc1, pc2, options);
}
});
}