mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
Update web-platform-tests to revision 14cfa4d648cc1c853b4153268df672d21425f8c1
This commit is contained in:
parent
1b73cf3352
commit
75736751d9
1213 changed files with 19434 additions and 12344 deletions
|
@ -0,0 +1,222 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>RTCPeerConnection.prototype.setRemoteDescription - add/remove remote tracks</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="RTCPeerConnection-helper.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
// Test is based on the following editor draft:
|
||||
// https://w3c.github.io/webrtc-pc/archives/20171002/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// getUserMediaTracksAndStreams
|
||||
// performOffer
|
||||
// Resolver
|
||||
|
||||
// These tests are concerned with the observable consequences of processing
|
||||
// the addition or removal of remote tracks, including events firing and the
|
||||
// states of RTCPeerConnection, MediaStream and MediaStreamTrack.
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
return getUserMediaTracksAndStreams(1)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
let localTrack = tracks[0];
|
||||
caller.addTrack(localTrack);
|
||||
let offerPromise = performOffer(caller, callee);
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
let remoteTrack = trackEvent.track;
|
||||
assert_equals(remoteTrack.id, localTrack.id,
|
||||
'Expected local and remote track IDs to match.');
|
||||
assert_equals(trackEvent.streams.length, 0,
|
||||
'Expected remote track not to belong to a stream.');
|
||||
t.done();
|
||||
});
|
||||
return offerPromise;
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'addTrack with a track and no stream makes ontrack fire with a track and no stream.');
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
return getUserMediaTracksAndStreams(1)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
let localTrack = tracks[0];
|
||||
let localStream = streams[0];
|
||||
caller.addTrack(localTrack, localStream);
|
||||
let offerPromise = performOffer(caller, callee);
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
assert_equals(trackEvent.streams.length, 1,
|
||||
'Expected track event to fire with a single stream.');
|
||||
let remoteTrack = trackEvent.track;
|
||||
let remoteStream = trackEvent.streams[0];
|
||||
assert_equals(remoteTrack.id, localTrack.id,
|
||||
'Expected local and remote track IDs to match.');
|
||||
assert_equals(remoteStream.id, localStream.id,
|
||||
'Expected local and remote stream IDs to match.');
|
||||
assert_array_equals(remoteStream.getTracks(), [remoteTrack],
|
||||
'Expected the remote stream\'s tracks to be the remote track.');
|
||||
t.done();
|
||||
});
|
||||
return offerPromise;
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'addTrack with a track and a stream makes ontrack fire with a track and a stream.');
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
return getUserMediaTracksAndStreams(2)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
let localTrack1 = tracks[0];
|
||||
let localTrack2 = tracks[1];
|
||||
let localStream = streams[0];
|
||||
caller.addTrack(localTrack1, localStream);
|
||||
caller.addTrack(localTrack2, localStream);
|
||||
let offerPromise = performOffer(caller, callee);
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
assert_equals(trackEvent.streams.length, 1,
|
||||
'Expected track event to fire with a single stream.');
|
||||
let remoteTrack1 = trackEvent.track;
|
||||
let remoteStream = trackEvent.streams[0];
|
||||
assert_equals(remoteTrack1.id, localTrack1.id,
|
||||
'Expected first remote track ID to match first local track ID.');
|
||||
assert_equals(remoteStream.getTracks().length, 2,
|
||||
'Expected the remote stream to contain two tracks.');
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
assert_equals(trackEvent.streams.length, 1,
|
||||
'Expected track event to fire with a single stream.');
|
||||
let remoteTrack2 = trackEvent.track;
|
||||
assert_equals(trackEvent.streams[0], remoteStream,
|
||||
'Expected both track events to fire with the same remote stream.');
|
||||
assert_equals(remoteTrack2.id, localTrack2.id,
|
||||
'Expected second remote track ID to match second local track ID.');
|
||||
assert_equals(remoteStream.getTracks().length, 2,
|
||||
'Expected the remote stream to contain two tracks.');
|
||||
assert_array_equals(remoteStream.getTracks(), [remoteTrack1, remoteTrack2],
|
||||
'Expected the remote stream\'s tracks to be the [first, second] remote tracks.');
|
||||
t.done();
|
||||
});
|
||||
});
|
||||
return offerPromise;
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'addTrack with two tracks and one stream makes ontrack fire twice with the tracks and shared stream.');
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
return getUserMediaTracksAndStreams(2)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
let localTrack = tracks[0];
|
||||
let localStreams = streams;
|
||||
caller.addTrack(localTrack, localStreams[0], localStreams[1]);
|
||||
let performOffer = performOffer(caller, callee);
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
assert_equals(trackEvent.streams.length, 2,
|
||||
'Expected the track event to fire with two streams.');
|
||||
let remoteTrack = trackEvent.track;
|
||||
let remoteStreams = trackEvent.streams;
|
||||
assert_equals(remoteTrack.id, localTrack.id,
|
||||
'Expected local and remote track IDs to match.');
|
||||
assert_equals(remoteStreams[0].id, localStreams[0].id,
|
||||
'Expected the first remote stream ID to match the first local stream ID.');
|
||||
assert_equals(remoteStreams[1].id, localStreams[1].id,
|
||||
'Expected the second remote stream ID to match the second local stream ID.');
|
||||
assert_array_equals(remoteStreams[0].getTracks(), [remoteTrack],
|
||||
'Expected the remote stream\'s tracks to be the remote track.');
|
||||
assert_array_equals(remoteStreams[1].getTracks(), [remoteTrack],
|
||||
'Expected the remote stream\'s tracks to be the remote track.');
|
||||
t.done();
|
||||
});
|
||||
return performOffer;
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'addTrack with a track and two streams makes ontrack fire with a track and two streams.');
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
let eventSequence = '';
|
||||
return getUserMediaTracksAndStreams(1)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
caller.addTrack(tracks[0]);
|
||||
let ontrackResolver = new Resolver();
|
||||
callee.ontrack = () => {
|
||||
eventSequence += 'ontrack;';
|
||||
ontrackResolver.resolve();
|
||||
}
|
||||
return Promise.all([
|
||||
ontrackResolver.promise,
|
||||
performOffer(caller, callee).then(() => {
|
||||
eventSequence += 'setRemoteDescription;';
|
||||
})
|
||||
]);
|
||||
}))
|
||||
.then(t.step_func(() => {
|
||||
assert_equals(eventSequence, 'ontrack;setRemoteDescription;');
|
||||
t.done();
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'ontrack fires before setRemoteDescription resolves.');
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
return getUserMediaTracksAndStreams(1)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
caller.addTrack(tracks[0]);
|
||||
let offerPromise = performOffer(caller, callee);
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
assert_array_equals(callee.getReceivers(), [trackEvent.receiver]);
|
||||
t.done();
|
||||
});
|
||||
return offerPromise;
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'ontrack\'s receiver matches getReceivers().');
|
||||
|
||||
async_test(t => {
|
||||
const caller = new RTCPeerConnection();
|
||||
const callee = new RTCPeerConnection();
|
||||
return getUserMediaTracksAndStreams(1)
|
||||
.then(t.step_func(([tracks, streams]) => {
|
||||
let sender = caller.addTrack(tracks[0]);
|
||||
assert_true(sender != null);
|
||||
let offerPromise = performOffer(caller, callee);
|
||||
callee.ontrack = t.step_func(trackEvent => {
|
||||
let receivers = callee.getReceivers();
|
||||
assert_equals(receivers.length, 1,
|
||||
'Expected getReceivers() to be the track event\'s receiver.');
|
||||
caller.removeTrack(sender);
|
||||
performOffer(caller, callee)
|
||||
.then(t.step_func(() => {
|
||||
assert_array_equals(callee.getReceivers(), receivers,
|
||||
'Expected the set of receivers to remain the same.');
|
||||
t.done();
|
||||
}));
|
||||
});
|
||||
return offerPromise;
|
||||
}))
|
||||
.catch(t.step_func(reason => {
|
||||
assert_unreached(reason);
|
||||
}));
|
||||
}, 'removeTrack does not remove the receiver.');
|
||||
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue