mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Update web-platform-tests to revision e529eb9501876273c9612f5602bc530723a01147
This commit is contained in:
parent
d7d56454b0
commit
4702cbe05c
113 changed files with 2705 additions and 1008 deletions
|
@ -303,21 +303,36 @@ function listenForSSRCs(t, receiver) {
|
|||
});
|
||||
}
|
||||
|
||||
// Helper function to create a pair of connected data channel.
|
||||
// Helper function to create a pair of connected data channels.
|
||||
// On success the promise resolves to an array with two data channels.
|
||||
// It does the heavy lifting of performing signaling handshake,
|
||||
// ICE candidate exchange, and waiting for data channel at two
|
||||
// end points to open.
|
||||
async function createDataChannelPair(
|
||||
pc1 = new RTCPeerConnection(),
|
||||
pc2 = new RTCPeerConnection()) {
|
||||
const pair = [pc1, pc2].map(pc =>
|
||||
pc.createDataChannel('', {negotiated: true, id: 0}));
|
||||
const bothOpen = Promise.all(pair.map(dc => new Promise((r, e) => {
|
||||
dc.onopen = r;
|
||||
dc.onerror = ({error}) => e(error);
|
||||
})));
|
||||
// end points to open. Can do both negotiated and non-negotiated setup.
|
||||
async function createDataChannelPair(t, options,
|
||||
pc1 = createPeerConnectionWithCleanup(t),
|
||||
pc2 = createPeerConnectionWithCleanup(t)) {
|
||||
let pair = [], bothOpen;
|
||||
try {
|
||||
if (options.negotiated) {
|
||||
pair = [pc1, pc2].map(pc => pc.createDataChannel('', options));
|
||||
bothOpen = Promise.all(pair.map(dc => new Promise((r, e) => {
|
||||
dc.onopen = r;
|
||||
dc.onerror = ({error}) => e(error);
|
||||
})));
|
||||
} else {
|
||||
pair = [pc1.createDataChannel('', options)];
|
||||
bothOpen = Promise.all([
|
||||
new Promise((r, e) => {
|
||||
pair[0].onopen = r;
|
||||
pair[0].onerror = ({error}) => e(error);
|
||||
}),
|
||||
new Promise((r, e) => pc2.ondatachannel = ({channel}) => {
|
||||
pair[1] = channel;
|
||||
channel.onopen = r;
|
||||
channel.onerror = ({error}) => e(error);
|
||||
})
|
||||
]);
|
||||
}
|
||||
exchangeIceCandidates(pc1, pc2);
|
||||
await exchangeOfferAnswer(pc1, pc2);
|
||||
await bothOpen;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue