mirror of
https://github.com/servo/servo.git
synced 2025-08-23 14:25:33 +01:00
Update web-platform-tests to revision 064f51c50eab34723ef435e80188bde08f718c2c
This commit is contained in:
parent
348f5520ee
commit
3c4e5d8f18
44 changed files with 769 additions and 789 deletions
|
@ -276,19 +276,6 @@
|
|||
createAnswer to mark the corresponding media description as sendrecv
|
||||
or sendonly and add the MSID of the track added, as defined in [JSEP]
|
||||
(section 5.2.2. and section 5.3.2.).
|
||||
9. A track could have contents that are inaccessible to the application.
|
||||
This can be due to being marked with a peerIdentity option or anything
|
||||
that would make a track CORS cross-origin. These tracks can be supplied
|
||||
to the addTrack method, and have an RTCRtpSender created for them, but
|
||||
content must not be transmitted, unless they are also marked with
|
||||
peerIdentity and they meet the requirements for sending (see isolated
|
||||
streams and RTCPeerConnection).
|
||||
|
||||
All other tracks that are not accessible to the application must not be
|
||||
sent to the peer, with silence (audio), black frames (video) or
|
||||
equivalently absent content being sent in place of track content.
|
||||
|
||||
Note that this property can change over time.
|
||||
|
||||
Non-Testable
|
||||
5.1. addTrack
|
||||
|
|
|
@ -23,9 +23,6 @@ const testArgs = {
|
|||
'undefined': false,
|
||||
'{}': false,
|
||||
|
||||
// peerIdentity
|
||||
'{ peerIdentity: toStringThrows }': new Error,
|
||||
|
||||
// certificates
|
||||
'{ certificates: null }': new TypeError,
|
||||
'{ certificates: undefined }': false,
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170515/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer()
|
||||
// generateAnswer()
|
||||
// generateDataChannelOffer()
|
||||
|
||||
/*
|
||||
* 4.3.2. createAnswer()
|
||||
|
@ -39,7 +38,7 @@
|
|||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer => pc.setRemoteDescription(offer))
|
||||
.then(() => pc.createAnswer())
|
||||
.then(answer => {
|
||||
|
@ -56,7 +55,7 @@
|
|||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then(offer => pc.setRemoteDescription(offer))
|
||||
.then(() => {
|
||||
pc.close();
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170515/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer()
|
||||
// generateAnswer()
|
||||
// countAudioLine()
|
||||
// countVideoLine()
|
||||
// assert_session_desc_similar()
|
||||
|
@ -49,7 +47,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => {
|
||||
|
@ -113,93 +111,4 @@
|
|||
* 5. If this inspection failed for any reason, reject p with a newly created
|
||||
* OperationError and abort these steps.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 4.3.3.2 Configuration data extensions
|
||||
* partial dictionary RTCOfferOptions
|
||||
*/
|
||||
|
||||
/*
|
||||
* offerToReceiveAudio of type boolean
|
||||
* When this is given a non-false value, no outgoing track of type
|
||||
* "audio" is attached to the PeerConnection, and the existing
|
||||
* localDescription (if any) doesn't contain any sendrecv or recv
|
||||
* audio media sections, createOffer() will behave as if
|
||||
* addTransceiver("audio") had been called once prior to the createOffer() call.
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
.then(offer1 => {
|
||||
assert_equals(countAudioLine(offer1.sdp), 1,
|
||||
'Expect created offer to have audio line');
|
||||
|
||||
// The first createOffer implicitly calls addTransceiver('audio'),
|
||||
// so all following offers will also have audio media section
|
||||
// in their SDP.
|
||||
return pc.createOffer({ offerToReceiveAudio: false })
|
||||
.then(offer2 => {
|
||||
assert_equals(countAudioLine(offer2.sdp), 1,
|
||||
'Expect audio line to remain in created offer');
|
||||
})
|
||||
});
|
||||
}, 'createOffer() with offerToReceiveAudio should add audio line to all subsequent created offers');
|
||||
|
||||
/*
|
||||
* offerToReceiveVideo of type boolean
|
||||
* When this is given a non-false value, and no outgoing track
|
||||
* of type "video" is attached to the PeerConnection, and the
|
||||
* existing localDescription (if any) doesn't contain any sendecv
|
||||
* or recv video media sections, createOffer() will behave as if
|
||||
* addTransceiver("video") had been called prior to the createOffer() call.
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
.then(offer1 => {
|
||||
assert_equals(countVideoLine(offer1.sdp), 1,
|
||||
'Expect created offer to have video line');
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: false })
|
||||
.then(offer2 => {
|
||||
assert_equals(countVideoLine(offer2.sdp), 1,
|
||||
'Expect video line to remain in created offer');
|
||||
})
|
||||
});
|
||||
}, 'createOffer() with offerToReceiveVideo should add video line to all subsequent created offers');
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({
|
||||
offerToReceiveAudio: true,
|
||||
offerToReceiveVideo: false
|
||||
}).then(offer1 => {
|
||||
assert_equals(countAudioLine(offer1.sdp), 1,
|
||||
'Expect audio line to be found in created offer');
|
||||
|
||||
assert_equals(countVideoLine(offer1.sdp), 0,
|
||||
'Expect video line to not found in create offer');
|
||||
|
||||
return pc.createOffer({
|
||||
offerToReceiveAudio: false,
|
||||
offerToReceiveVideo: true
|
||||
}).then(offer2 => {
|
||||
assert_equals(countAudioLine(offer2.sdp), 1,
|
||||
'Expect audio line to remain in created offer');
|
||||
|
||||
assert_equals(countVideoLine(offer2.sdp), 1,
|
||||
'Expect video line to be found in create offer');
|
||||
})
|
||||
});
|
||||
}, 'createOffer() with offerToReceiveAudio:true then offerToReceiveVideo:true should have result offer with both audio and video line');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -103,73 +103,41 @@ function assert_session_desc_not_similar(sessionDesc1, sessionDesc2) {
|
|||
'Expect both session descriptions to have different count of media lines');
|
||||
}
|
||||
|
||||
// Helper function to generate offer using a freshly created RTCPeerConnection
|
||||
// object with any audio, video, data media lines present
|
||||
function generateOffer(options={}) {
|
||||
const {
|
||||
audio = false,
|
||||
video = false,
|
||||
data = false,
|
||||
pc,
|
||||
} = options;
|
||||
async function generateDataChannelOffer(pc) {
|
||||
pc.createDataChannel('test');
|
||||
const offer = await pc.createOffer();
|
||||
assert_equals(countApplicationLine(offer.sdp), 1, 'Expect m=application line to be present in generated SDP');
|
||||
return offer;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
pc.createDataChannel('test');
|
||||
}
|
||||
|
||||
const setup = {};
|
||||
|
||||
if (audio) {
|
||||
setup.offerToReceiveAudio = true;
|
||||
}
|
||||
|
||||
if (video) {
|
||||
setup.offerToReceiveVideo = true;
|
||||
}
|
||||
|
||||
return pc.createOffer(setup).then(offer => {
|
||||
// Guard here to ensure that the generated offer really
|
||||
// contain the number of media lines we want
|
||||
const { sdp } = offer;
|
||||
|
||||
if(audio) {
|
||||
assert_equals(countAudioLine(sdp), 1,
|
||||
'Expect m=audio line to be present in generated SDP');
|
||||
} else {
|
||||
assert_equals(countAudioLine(sdp), 0,
|
||||
'Expect m=audio line to be present in generated SDP');
|
||||
async function generateAudioReceiveOnlyOffer(pc)
|
||||
{
|
||||
try {
|
||||
pc.addTransceiver('audio', { direction: 'recvonly' });
|
||||
return pc.createOffer();
|
||||
} catch(e) {
|
||||
return pc.createOffer({ offerToReceiveAudio: true });
|
||||
}
|
||||
}
|
||||
|
||||
if(video) {
|
||||
assert_equals(countVideoLine(sdp), 1,
|
||||
'Expect m=video line to be present in generated SDP');
|
||||
} else {
|
||||
assert_equals(countVideoLine(sdp), 0,
|
||||
'Expect m=video line to not present in generated SDP');
|
||||
async function generateVideoReceiveOnlyOffer(pc)
|
||||
{
|
||||
try {
|
||||
pc.addTransceiver('video', { direction: 'recvonly' });
|
||||
return pc.createOffer();
|
||||
} catch(e) {
|
||||
return pc.createOffer({ offerToReceiveVideo: true });
|
||||
}
|
||||
|
||||
if(data) {
|
||||
assert_equals(countApplicationLine(sdp), 1,
|
||||
'Expect m=application line to be present in generated SDP');
|
||||
} else {
|
||||
assert_equals(countApplicationLine(sdp), 0,
|
||||
'Expect m=application line to not present in generated SDP');
|
||||
}
|
||||
|
||||
return offer;
|
||||
});
|
||||
}
|
||||
|
||||
// Helper function to generate answer based on given offer using a freshly
|
||||
// created RTCPeerConnection object
|
||||
function generateAnswer(offer) {
|
||||
async function generateAnswer(offer) {
|
||||
const pc = new RTCPeerConnection();
|
||||
return pc.setRemoteDescription(offer)
|
||||
.then(() => pc.createAnswer())
|
||||
.then((answer) => {
|
||||
pc.close();
|
||||
return answer;
|
||||
});
|
||||
await pc.setRemoteDescription(offer);
|
||||
const answer = await pc.createAnswer();
|
||||
pc.close();
|
||||
return answer;
|
||||
}
|
||||
|
||||
// Run a test function that return a promise that should
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer
|
||||
// generateAnswer
|
||||
// assert_session_desc_similar
|
||||
|
||||
|
@ -65,7 +64,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => pc.createAnswer())
|
||||
|
@ -97,7 +96,7 @@
|
|||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => pc.createAnswer())
|
||||
|
@ -128,7 +127,7 @@
|
|||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => generateAnswer(offer))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer
|
||||
// generateDataChannelOffer
|
||||
// assert_session_desc_not_similar
|
||||
// assert_session_desc_similar
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
return generateAudioReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => {
|
||||
|
@ -84,7 +84,7 @@
|
|||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc.close());
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
return generateAudioReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription({ type: 'offer' })
|
||||
.then(() => {
|
||||
|
@ -109,7 +109,7 @@
|
|||
|
||||
t.add_cleanup(() => pc2.close());
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then(offer =>
|
||||
promise_rejects(t, 'InvalidModificationError',
|
||||
pc2.setLocalDescription(offer)));
|
||||
|
@ -122,9 +122,9 @@
|
|||
// with the first offer
|
||||
const pc = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc.close());
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
return generateAudioReceiveOnlyOffer(pc)
|
||||
.then(offer1 =>
|
||||
pc.createOffer({ offerToReceiveVideo: true })
|
||||
generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer2 => {
|
||||
assert_session_desc_not_similar(offer1, offer2);
|
||||
return promise_rejects(t, 'InvalidModificationError',
|
||||
|
@ -139,11 +139,11 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
return generateAudioReceiveOnlyOffer(pc)
|
||||
.then(offer1 =>
|
||||
pc.setLocalDescription(offer1)
|
||||
.then(() =>
|
||||
pc.createOffer({ offerToReceiveVideo: true })
|
||||
generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer2 =>
|
||||
pc.setLocalDescription(offer2)
|
||||
.then(offer2 => {
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer
|
||||
// generateAnswer
|
||||
// assert_session_desc_similar
|
||||
|
||||
/*
|
||||
|
@ -86,7 +84,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => pc.createAnswer())
|
||||
|
@ -119,7 +117,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => pc.createAnswer())
|
||||
|
@ -141,7 +139,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setRemoteDescription(offer)
|
||||
.then(() => pc.createAnswer())
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer
|
||||
// generateDataChannelOffer
|
||||
// assert_session_desc_not_similar
|
||||
// assert_session_desc_similar
|
||||
|
||||
|
@ -50,14 +50,14 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
return generateAudioReceiveOnlyOffer(pc)
|
||||
.then(offer1 =>
|
||||
pc.setLocalDescription(offer1)
|
||||
.then(() => generateAnswer(offer1))
|
||||
.then(answer => pc.setRemoteDescription(answer))
|
||||
.then(() => {
|
||||
pc.createDataChannel('test');
|
||||
return pc.createOffer({ offerToReceiveVideo: true });
|
||||
return generateVideoReceiveOnlyOffer(pc);
|
||||
})
|
||||
.then(offer2 =>
|
||||
pc.setLocalDescription(offer2)
|
||||
|
@ -79,12 +79,12 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then(offer => pc.setRemoteDescription(offer))
|
||||
.then(() => pc.createAnswer())
|
||||
.then(answer =>
|
||||
pc.setLocalDescription(answer)
|
||||
.then(() => pc.createOffer({ offerToReceiveVideo: true }))
|
||||
.then(() => generateVideoReceiveOnlyOffer(pc))
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer()
|
||||
// generateAnswer()
|
||||
// assert_session_desc_similar()
|
||||
|
||||
|
@ -64,7 +63,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => generateAnswer(offer))
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer
|
||||
// generateAnswer
|
||||
// assert_session_desc_similar
|
||||
|
||||
|
@ -86,7 +85,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => generateAnswer(offer))
|
||||
|
@ -117,7 +116,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => generateAnswer(offer))
|
||||
|
@ -139,7 +138,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
return generateVideoReceiveOnlyOffer(pc)
|
||||
.then(offer =>
|
||||
pc.setLocalDescription(offer)
|
||||
.then(() => generateAnswer(offer))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer
|
||||
// generateDataChannelOffer
|
||||
// assert_session_desc_similar
|
||||
|
||||
/*
|
||||
|
@ -63,7 +63,7 @@
|
|||
const states = [];
|
||||
pc.addEventListener('signalingstatechange', () => states.push(pc.signalingState));
|
||||
|
||||
return generateOffer({ data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then(offer => pc.setRemoteDescription(offer))
|
||||
.then(() => {
|
||||
assert_equals(pc.signalingState, 'have-remote-offer');
|
||||
|
|
|
@ -91,7 +91,7 @@
|
|||
assert_equals(state, states[eventCount]);
|
||||
};
|
||||
|
||||
const offer = await pc.createOffer({ offerToReceiveAudio: true });
|
||||
const offer = await generateAudioReceiveOnlyOffer(pc);
|
||||
assert_state('stable');
|
||||
await pc.setLocalDescription(offer);
|
||||
assert_state('have-local-offer');
|
||||
|
@ -111,10 +111,10 @@
|
|||
t.add_cleanup(() => pc.close());
|
||||
t.add_cleanup(() => pc2.close());
|
||||
|
||||
const offer1 = await pc2.createOffer({ offerToReceiveAudio: true });
|
||||
const offer1 = await generateAudioReceiveOnlyOffer(pc2);
|
||||
await pc.setRemoteDescription(offer1);
|
||||
await pc.setLocalDescription(await pc.createAnswer());
|
||||
const offer2 = await pc2.createOffer({ offerToReceiveVideo: true });
|
||||
const offer2 = await generateVideoReceiveOnlyOffer(pc2);
|
||||
await pc.setRemoteDescription(offer2);
|
||||
assert_session_desc_not_similar(offer1, offer2);
|
||||
assert_session_desc_similar(pc.remoteDescription, offer2);
|
||||
|
@ -128,7 +128,7 @@
|
|||
t.add_cleanup(() => pc.close());
|
||||
t.add_cleanup(() => pc2.close());
|
||||
|
||||
const offer = await pc.createOffer({ offerToReceiveAudio: true });
|
||||
const offer = await generateAudioReceiveOnlyOffer(pc);
|
||||
await pc.setLocalDescription(offer);
|
||||
await pc2.setRemoteDescription(offer);
|
||||
const answer = await pc2.createAnswer();
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
const { receiver } = pc.addTransceiver('audio');
|
||||
const param = pc.getParameters();
|
||||
const param = receiver.getParameters();
|
||||
validateReceiverRtpParameters(param);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -49,6 +49,12 @@
|
|||
t.add_cleanup(() => caller.close());
|
||||
const callee = new RTCPeerConnection();
|
||||
t.add_cleanup(() => callee.close());
|
||||
|
||||
const stream = await getNoiseStream({audio:true});
|
||||
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
|
||||
const [track] = stream.getTracks();
|
||||
callee.addTrack(track);
|
||||
|
||||
const { receiver } = caller.addTransceiver('audio');
|
||||
|
||||
await doSignalingHandshake(caller, callee);
|
||||
|
|
|
@ -44,7 +44,11 @@
|
|||
t.add_cleanup(() => caller.close());
|
||||
const callee = new RTCPeerConnection();
|
||||
t.add_cleanup(() => callee.close());
|
||||
const { sender } = caller.addTransceiver('audio');
|
||||
|
||||
const stream = await getNoiseStream({audio:true});
|
||||
t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));
|
||||
const [track] = stream.getTracks();
|
||||
const { sender } = caller.addTransceiver(track);
|
||||
|
||||
await doSignalingHandshake(caller, callee);
|
||||
const statsReport = await sender.getStats();
|
||||
|
|
|
@ -305,125 +305,6 @@
|
|||
]);
|
||||
};
|
||||
|
||||
const checkAddTransceiverWithStream = async t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
const audioStream = await navigator.mediaDevices.getUserMedia({audio: true});
|
||||
const videoStream = await navigator.mediaDevices.getUserMedia({video: true});
|
||||
t.add_cleanup(() => stopTracks(audioStream, videoStream));
|
||||
|
||||
const audio = audioStream.getAudioTracks()[0];
|
||||
const video = videoStream.getVideoTracks()[0];
|
||||
|
||||
pc.addTransceiver(audio, {streams: [audioStream]});
|
||||
pc.addTransceiver(video, {streams: [videoStream]});
|
||||
|
||||
hasProps(pc.getTransceivers(),
|
||||
[
|
||||
{
|
||||
receiver: {track: {kind: "audio"}},
|
||||
sender: {track: audio},
|
||||
direction: "sendrecv",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
},
|
||||
{
|
||||
receiver: {track: {kind: "video"}},
|
||||
sender: {track: video},
|
||||
direction: "sendrecv",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
}
|
||||
]);
|
||||
|
||||
const offer = await pc.createOffer();
|
||||
assert_true(offer.sdp.includes("a=msid:" + audioStream.id + " " + audio.id),
|
||||
"offer contains the expected audio msid");
|
||||
assert_true(offer.sdp.includes("a=msid:" + videoStream.id + " " + video.id),
|
||||
"offer contains the expected video msid");
|
||||
};
|
||||
|
||||
const checkAddTransceiverWithOfferToReceive = async (t, kinds) => {
|
||||
const pc = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
const propsToSet = kinds.map(kind => {
|
||||
if (kind == "audio") {
|
||||
return "offerToReceiveAudio";
|
||||
} else if (kind == "video") {
|
||||
return "offerToReceiveVideo";
|
||||
}
|
||||
});
|
||||
|
||||
const options = {};
|
||||
|
||||
for (const prop of propsToSet) {
|
||||
options[prop] = true;
|
||||
}
|
||||
|
||||
let offer = await pc.createOffer(options);
|
||||
|
||||
const expected = [];
|
||||
|
||||
if (options.offerToReceiveAudio) {
|
||||
expected.push(
|
||||
{
|
||||
receiver: {track: {kind: "audio"}},
|
||||
sender: {track: null},
|
||||
direction: "recvonly",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
});
|
||||
}
|
||||
|
||||
if (options.offerToReceiveVideo) {
|
||||
expected.push(
|
||||
{
|
||||
receiver: {track: {kind: "video"}},
|
||||
sender: {track: null},
|
||||
direction: "recvonly",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
});
|
||||
}
|
||||
|
||||
hasProps(pc.getTransceivers(), expected);
|
||||
|
||||
// Test offerToReceive: false
|
||||
for (const prop of propsToSet) {
|
||||
options[prop] = false;
|
||||
}
|
||||
|
||||
// Check that sendrecv goes to sendonly
|
||||
for (const transceiver of pc.getTransceivers()) {
|
||||
transceiver.direction = "sendrecv";
|
||||
}
|
||||
|
||||
for (const transceiverCheck of expected) {
|
||||
transceiverCheck.direction = "sendonly";
|
||||
}
|
||||
|
||||
offer = await pc.createOffer(options);
|
||||
hasProps(pc.getTransceivers(), expected);
|
||||
|
||||
// Check that recvonly goes to inactive
|
||||
for (const transceiver of pc.getTransceivers()) {
|
||||
transceiver.direction = "recvonly";
|
||||
}
|
||||
|
||||
for (const transceiverCheck of expected) {
|
||||
transceiverCheck.direction = "inactive";
|
||||
}
|
||||
|
||||
offer = await pc.createOffer(options);
|
||||
hasProps(pc.getTransceivers(), expected);
|
||||
};
|
||||
|
||||
const checkAddTransceiverWithSetRemoteOfferSending = async t => {
|
||||
const pc1 = new RTCPeerConnection();
|
||||
const pc2 = new RTCPeerConnection();
|
||||
|
@ -1248,70 +1129,6 @@
|
|||
assert_equals(2, countUnmuteVideo2.count, "Got 2 unmute events for pc2's video track");
|
||||
};
|
||||
|
||||
const checkOnAddStream = async t => {
|
||||
const pc1 = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc1.close());
|
||||
const stream1 = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
||||
t.add_cleanup(() => stopTracks(stream1));
|
||||
const audio1 = stream1.getAudioTracks()[0];
|
||||
pc1.addTrack(audio1, stream1);
|
||||
const video1 = stream1.getVideoTracks()[0];
|
||||
pc1.addTrack(video1, stream1);
|
||||
|
||||
const pc2 = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc2.close());
|
||||
const stream2 = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
||||
t.add_cleanup(() => stopTracks(stream2));
|
||||
const audio2 = stream2.getAudioTracks()[0];
|
||||
pc2.addTrack(audio2, stream2);
|
||||
const video2 = stream2.getVideoTracks()[0];
|
||||
pc2.addTrack(video2, stream2);
|
||||
|
||||
const offer = await pc1.createOffer();
|
||||
|
||||
let trackEventCollector = collectTrackEvents(pc2);
|
||||
let addstreamEventCollector = collectEvents(pc2, "addstream", e => {
|
||||
hasProps(e, {stream: {id: stream1.id}});
|
||||
assert_equals(e.stream.getAudioTracks().length, 1, "One audio track");
|
||||
assert_equals(e.stream.getVideoTracks().length, 1, "One video track");
|
||||
});
|
||||
|
||||
await pc2.setRemoteDescription(offer);
|
||||
|
||||
let addstreamEvents = addstreamEventCollector.finish();
|
||||
assert_equals(addstreamEvents.length, 1, "Should have 1 addstream event");
|
||||
|
||||
let trackEvents = trackEventCollector.finish();
|
||||
|
||||
hasProps(trackEvents,
|
||||
[
|
||||
{streams: [addstreamEvents[0].stream]},
|
||||
{streams: [addstreamEvents[0].stream]}
|
||||
]);
|
||||
|
||||
await pc1.setLocalDescription(offer);
|
||||
const answer = await pc2.createAnswer();
|
||||
|
||||
trackEventCollector = collectTrackEvents(pc1);
|
||||
addstreamEventCollector = collectEvents(pc1, "addstream", e => {
|
||||
hasProps(e, {stream: {id: stream2.id}});
|
||||
assert_equals(e.stream.getAudioTracks().length, 1, "One audio track");
|
||||
assert_equals(e.stream.getVideoTracks().length, 1, "One video track");
|
||||
});
|
||||
|
||||
await pc1.setRemoteDescription(answer);
|
||||
addstreamEvents = addstreamEventCollector.finish();
|
||||
assert_equals(addstreamEvents.length, 1, "Should have 1 addstream event");
|
||||
|
||||
trackEvents = trackEventCollector.finish();
|
||||
|
||||
hasProps(trackEvents,
|
||||
[
|
||||
{streams: [addstreamEvents[0].stream]},
|
||||
{streams: [addstreamEvents[0].stream]}
|
||||
]);
|
||||
};
|
||||
|
||||
const checkStop = async t => {
|
||||
const pc1 = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc1.close());
|
||||
|
@ -2312,16 +2129,6 @@ const tests = [
|
|||
checkAddTransceiverWithTrack,
|
||||
checkAddTransceiverWithAddTrack,
|
||||
checkAddTransceiverWithDirection,
|
||||
checkAddTransceiverWithStream,
|
||||
function checkAddTransceiverWithOfferToReceiveAudio(t) {
|
||||
return checkAddTransceiverWithOfferToReceive(t, ["audio"]);
|
||||
},
|
||||
function checkAddTransceiverWithOfferToReceiveVideo(t) {
|
||||
return checkAddTransceiverWithOfferToReceive(t, ["video"]);
|
||||
},
|
||||
function checkAddTransceiverWithOfferToReceiveBoth(t) {
|
||||
return checkAddTransceiverWithOfferToReceive(t, ["audio", "video"]);
|
||||
},
|
||||
checkAddTransceiverWithSetRemoteOfferSending,
|
||||
checkAddTransceiverWithSetRemoteOfferNoSend,
|
||||
checkAddTransceiverBadKind,
|
||||
|
@ -2340,7 +2147,6 @@ const tests = [
|
|||
checkAddTrackExistingTransceiverThenRemove,
|
||||
checkRemoveTrackNegotiation,
|
||||
checkMute,
|
||||
checkOnAddStream,
|
||||
checkStop,
|
||||
checkStopAfterCreateOffer,
|
||||
checkStopAfterSetLocalOffer,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
|
||||
|
||||
// The following helper functions are called from RTCPeerConnection-helper.js:
|
||||
// generateOffer()
|
||||
// generateDataChannelOffer()
|
||||
// generateAnswer()
|
||||
|
||||
/*
|
||||
|
@ -69,7 +69,7 @@
|
|||
t.add_cleanup(() => pc.close());
|
||||
assert_equals(pc.sctp, null);
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then(offer => pc.setRemoteDescription(offer))
|
||||
.then(() => pc.createAnswer())
|
||||
.then(answer => pc.setLocalDescription(answer))
|
||||
|
|
|
@ -49,7 +49,7 @@ promise_test(t => {
|
|||
assert_equals(pc.sctp, null);
|
||||
let maxMessageSize;
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then((offer) => {
|
||||
assert_not_equals(mmsAttributeHelper.getValue(offer.sdp), null,
|
||||
'SDP should have max-message-size attribute');
|
||||
|
@ -73,7 +73,7 @@ promise_test(t => {
|
|||
t.add_cleanup(() => pc.close());
|
||||
assert_equals(pc.sctp, null);
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then((offer) => {
|
||||
assert_not_equals(mmsAttributeHelper.getValue(offer.sdp), null,
|
||||
'SDP should have max-message-size attribute');
|
||||
|
@ -102,7 +102,7 @@ promise_test(t => {
|
|||
t.add_cleanup(() => pc.close());
|
||||
assert_equals(pc.sctp, null);
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then((offer) => {
|
||||
assert_not_equals(mmsAttributeHelper.getValue(offer.sdp), null,
|
||||
'SDP should have max-message-size attribute');
|
||||
|
@ -124,7 +124,7 @@ promise_test(t => {
|
|||
t.add_cleanup(() => pc.close());
|
||||
assert_equals(pc.sctp, null);
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then((offer) => {
|
||||
assert_not_equals(mmsAttributeHelper.getValue(offer.sdp), null,
|
||||
'SDP should have max-message-size attribute');
|
||||
|
@ -160,7 +160,7 @@ promise_test(t => {
|
|||
assert_equals(pc.sctp, null);
|
||||
const largerThanCanSendSize = canSendSize + 1;
|
||||
|
||||
return generateOffer({ pc, data: true })
|
||||
return generateDataChannelOffer(pc)
|
||||
.then((offer) => {
|
||||
assert_not_equals(mmsAttributeHelper.getValue(offer.sdp), null,
|
||||
'SDP should have max-message-size attribute');
|
||||
|
|
|
@ -38,10 +38,6 @@ This test uses data only, and thus does not require fake media devices.
|
|||
}
|
||||
});
|
||||
|
||||
var onRemoteStream = test.step_func(function(event) {
|
||||
assert_unreached('WebRTC received a stream when there was none');
|
||||
});
|
||||
|
||||
var getStatsRecordByType = function(stats, type) {
|
||||
for (let stat of stats.values()) {
|
||||
if (stat.type == type) {
|
||||
|
@ -91,7 +87,6 @@ This test uses data only, and thus does not require fake media devices.
|
|||
|
||||
gSecondConnection = new RTCPeerConnection(null);
|
||||
gSecondConnection.onicecandidate = onIceCandidateToSecond;
|
||||
gSecondConnection.onaddstream = onRemoteStream;
|
||||
|
||||
// The createDataChannel is necessary and sufficient to make
|
||||
// sure the ICE connection be attempted.
|
||||
|
|
2
tests/wpt/web-platform-tests/webrtc/legacy/README.txt
Normal file
2
tests/wpt/web-platform-tests/webrtc/legacy/README.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
This directory contains files that test for behavior relevant to webrtc,
|
||||
particularly defined in https://w3c.github.io/webrtc-pc/#legacy-interface-extensions
|
|
@ -4,10 +4,99 @@
|
|||
<link rel="help" href="https://w3c.github.io/webrtc-pc/#legacy-configuration-extensions">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="RTCPeerConnection-helper.js"></script>
|
||||
<script src="../RTCPeerConnection-helper.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
/*
|
||||
* 4.3.3.2 Configuration data extensions
|
||||
* partial dictionary RTCOfferOptions
|
||||
*/
|
||||
|
||||
/*
|
||||
* offerToReceiveAudio of type boolean
|
||||
* When this is given a non-false value, no outgoing track of type
|
||||
* "audio" is attached to the PeerConnection, and the existing
|
||||
* localDescription (if any) doesn't contain any sendrecv or recv
|
||||
* audio media sections, createOffer() will behave as if
|
||||
* addTransceiver("audio") had been called once prior to the createOffer() call.
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveAudio: true })
|
||||
.then(offer1 => {
|
||||
assert_equals(countAudioLine(offer1.sdp), 1,
|
||||
'Expect created offer to have audio line');
|
||||
|
||||
// The first createOffer implicitly calls addTransceiver('audio'),
|
||||
// so all following offers will also have audio media section
|
||||
// in their SDP.
|
||||
return pc.createOffer({ offerToReceiveAudio: false })
|
||||
.then(offer2 => {
|
||||
assert_equals(countAudioLine(offer2.sdp), 1,
|
||||
'Expect audio line to remain in created offer');
|
||||
})
|
||||
});
|
||||
}, 'createOffer() with offerToReceiveAudio should add audio line to all subsequent created offers');
|
||||
|
||||
/*
|
||||
* offerToReceiveVideo of type boolean
|
||||
* When this is given a non-false value, and no outgoing track
|
||||
* of type "video" is attached to the PeerConnection, and the
|
||||
* existing localDescription (if any) doesn't contain any sendecv
|
||||
* or recv video media sections, createOffer() will behave as if
|
||||
* addTransceiver("video") had been called prior to the createOffer() call.
|
||||
*/
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: true })
|
||||
.then(offer1 => {
|
||||
assert_equals(countVideoLine(offer1.sdp), 1,
|
||||
'Expect created offer to have video line');
|
||||
|
||||
return pc.createOffer({ offerToReceiveVideo: false })
|
||||
.then(offer2 => {
|
||||
assert_equals(countVideoLine(offer2.sdp), 1,
|
||||
'Expect video line to remain in created offer');
|
||||
})
|
||||
});
|
||||
}, 'createOffer() with offerToReceiveVideo should add video line to all subsequent created offers');
|
||||
|
||||
promise_test(t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
return pc.createOffer({
|
||||
offerToReceiveAudio: true,
|
||||
offerToReceiveVideo: false
|
||||
}).then(offer1 => {
|
||||
assert_equals(countAudioLine(offer1.sdp), 1,
|
||||
'Expect audio line to be found in created offer');
|
||||
|
||||
assert_equals(countVideoLine(offer1.sdp), 0,
|
||||
'Expect video line to not be found in create offer');
|
||||
|
||||
return pc.createOffer({
|
||||
offerToReceiveAudio: false,
|
||||
offerToReceiveVideo: true
|
||||
}).then(offer2 => {
|
||||
assert_equals(countAudioLine(offer2.sdp), 1,
|
||||
'Expect audio line to remain in created offer');
|
||||
|
||||
assert_equals(countVideoLine(offer2.sdp), 1,
|
||||
'Expect video line to be found in create offer');
|
||||
})
|
||||
});
|
||||
}, 'createOffer() with offerToReceiveAudio:true, then with offerToReceiveVideo:true, should have result offer with both audio and video line');
|
||||
|
||||
|
||||
// Run some tests for both audio and video kinds
|
||||
['audio', 'video'].forEach((kind) => {
|
||||
const capsKind = kind[0].toUpperCase() + kind.slice(1);
|
|
@ -0,0 +1,169 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>RTCRtpTransceiver with OfferToReceive legacy options</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../RTCPeerConnection-helper.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const stopTracks = (...streams) => {
|
||||
streams.forEach(stream => stream.getTracks().forEach(track => track.stop()));
|
||||
};
|
||||
|
||||
// comparable() - produces copy of object that is JSON comparable.
|
||||
// o = original object (required)
|
||||
// t = template of what to examine. Useful if o is non-enumerable (optional)
|
||||
|
||||
const comparable = (o, t = o) => {
|
||||
if (typeof o != 'object' || !o) {
|
||||
return o;
|
||||
}
|
||||
if (Array.isArray(t) && Array.isArray(o)) {
|
||||
return o.map((n, i) => comparable(n, t[i]));
|
||||
}
|
||||
return Object.keys(t).sort()
|
||||
.reduce((r, key) => (r[key] = comparable(o[key], t[key]), r), {});
|
||||
};
|
||||
|
||||
const stripKeyQuotes = s => s.replace(/"(\w+)":/g, "$1:");
|
||||
|
||||
const hasProps = (observed, expected) => {
|
||||
const observable = comparable(observed, expected);
|
||||
assert_equals(stripKeyQuotes(JSON.stringify(observable)),
|
||||
stripKeyQuotes(JSON.stringify(comparable(expected))));
|
||||
};
|
||||
|
||||
const checkAddTransceiverWithStream = async t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
const audioStream = await navigator.mediaDevices.getUserMedia({audio: true});
|
||||
const videoStream = await navigator.mediaDevices.getUserMedia({video: true});
|
||||
t.add_cleanup(() => stopTracks(audioStream, videoStream));
|
||||
|
||||
const audio = audioStream.getAudioTracks()[0];
|
||||
const video = videoStream.getVideoTracks()[0];
|
||||
|
||||
pc.addTransceiver(audio, {streams: [audioStream]});
|
||||
pc.addTransceiver(video, {streams: [videoStream]});
|
||||
|
||||
hasProps(pc.getTransceivers(),
|
||||
[
|
||||
{
|
||||
receiver: {track: {kind: "audio"}},
|
||||
sender: {track: audio},
|
||||
direction: "sendrecv",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
},
|
||||
{
|
||||
receiver: {track: {kind: "video"}},
|
||||
sender: {track: video},
|
||||
direction: "sendrecv",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
}
|
||||
]);
|
||||
|
||||
const offer = await pc.createOffer();
|
||||
assert_true(offer.sdp.includes("a=msid:" + audioStream.id + " " + audio.id),
|
||||
"offer contains the expected audio msid");
|
||||
assert_true(offer.sdp.includes("a=msid:" + videoStream.id + " " + video.id),
|
||||
"offer contains the expected video msid");
|
||||
};
|
||||
|
||||
const checkAddTransceiverWithOfferToReceive = async (t, kinds) => {
|
||||
const pc = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc.close());
|
||||
|
||||
const propsToSet = kinds.map(kind => {
|
||||
if (kind == "audio") {
|
||||
return "offerToReceiveAudio";
|
||||
} else if (kind == "video") {
|
||||
return "offerToReceiveVideo";
|
||||
}
|
||||
});
|
||||
|
||||
const options = {};
|
||||
|
||||
for (const prop of propsToSet) {
|
||||
options[prop] = true;
|
||||
}
|
||||
|
||||
let offer = await pc.createOffer(options);
|
||||
|
||||
const expected = [];
|
||||
|
||||
if (options.offerToReceiveAudio) {
|
||||
expected.push(
|
||||
{
|
||||
receiver: {track: {kind: "audio"}},
|
||||
sender: {track: null},
|
||||
direction: "recvonly",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
});
|
||||
}
|
||||
|
||||
if (options.offerToReceiveVideo) {
|
||||
expected.push(
|
||||
{
|
||||
receiver: {track: {kind: "video"}},
|
||||
sender: {track: null},
|
||||
direction: "recvonly",
|
||||
mid: null,
|
||||
currentDirection: null,
|
||||
stopped: false
|
||||
});
|
||||
}
|
||||
|
||||
hasProps(pc.getTransceivers(), expected);
|
||||
|
||||
// Test offerToReceive: false
|
||||
for (const prop of propsToSet) {
|
||||
options[prop] = false;
|
||||
}
|
||||
|
||||
// Check that sendrecv goes to sendonly
|
||||
for (const transceiver of pc.getTransceivers()) {
|
||||
transceiver.direction = "sendrecv";
|
||||
}
|
||||
|
||||
for (const transceiverCheck of expected) {
|
||||
transceiverCheck.direction = "sendonly";
|
||||
}
|
||||
|
||||
offer = await pc.createOffer(options);
|
||||
hasProps(pc.getTransceivers(), expected);
|
||||
|
||||
// Check that recvonly goes to inactive
|
||||
for (const transceiver of pc.getTransceivers()) {
|
||||
transceiver.direction = "recvonly";
|
||||
}
|
||||
|
||||
for (const transceiverCheck of expected) {
|
||||
transceiverCheck.direction = "inactive";
|
||||
}
|
||||
|
||||
offer = await pc.createOffer(options);
|
||||
hasProps(pc.getTransceivers(), expected);
|
||||
};
|
||||
|
||||
const tests = [
|
||||
checkAddTransceiverWithStream,
|
||||
function checkAddTransceiverWithOfferToReceiveAudio(t) {
|
||||
return checkAddTransceiverWithOfferToReceive(t, ["audio"]);
|
||||
},
|
||||
function checkAddTransceiverWithOfferToReceiveVideo(t) {
|
||||
return checkAddTransceiverWithOfferToReceive(t, ["video"]);
|
||||
},
|
||||
function checkAddTransceiverWithOfferToReceiveBoth(t) {
|
||||
return checkAddTransceiverWithOfferToReceive(t, ["audio", "video"]);
|
||||
}
|
||||
].forEach(test => promise_test(test, test.name));
|
||||
|
||||
</script>
|
|
@ -0,0 +1,153 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>onaddstream tests</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
const stopTracks = (...streams) => {
|
||||
streams.forEach(stream => stream.getTracks().forEach(track => track.stop()));
|
||||
};
|
||||
|
||||
const collectEvents = (target, name, check) => {
|
||||
const events = [];
|
||||
const handler = e => {
|
||||
check(e);
|
||||
events.push(e);
|
||||
};
|
||||
|
||||
target.addEventListener(name, handler);
|
||||
|
||||
const finishCollecting = () => {
|
||||
target.removeEventListener(name, handler);
|
||||
return events;
|
||||
};
|
||||
|
||||
return {finish: finishCollecting};
|
||||
};
|
||||
|
||||
const collectAddTrackEvents = stream => {
|
||||
const checkEvent = e => {
|
||||
assert_true(e.track instanceof MediaStreamTrack, "Track is set on event");
|
||||
assert_true(stream.getTracks().includes(e.track),
|
||||
"track in addtrack event is in the stream");
|
||||
};
|
||||
return collectEvents(stream, "addtrack", checkEvent);
|
||||
};
|
||||
|
||||
const collectRemoveTrackEvents = stream => {
|
||||
const checkEvent = e => {
|
||||
assert_true(e.track instanceof MediaStreamTrack, "Track is set on event");
|
||||
assert_true(!stream.getTracks().includes(e.track),
|
||||
"track in removetrack event is not in the stream");
|
||||
};
|
||||
return collectEvents(stream, "removetrack", checkEvent);
|
||||
};
|
||||
|
||||
const collectTrackEvents = pc => {
|
||||
const checkEvent = e => {
|
||||
assert_true(e.track instanceof MediaStreamTrack, "Track is set on event");
|
||||
assert_true(e.receiver instanceof RTCRtpReceiver, "Receiver is set on event");
|
||||
assert_true(e.transceiver instanceof RTCRtpTransceiver, "Transceiver is set on event");
|
||||
assert_true(Array.isArray(e.streams), "Streams is set on event");
|
||||
e.streams.forEach(stream => {
|
||||
assert_true(stream.getTracks().includes(e.track),
|
||||
"Each stream in event contains the track");
|
||||
});
|
||||
assert_equals(e.receiver, e.transceiver.receiver,
|
||||
"Receiver belongs to transceiver");
|
||||
assert_equals(e.track, e.receiver.track,
|
||||
"Track belongs to receiver");
|
||||
};
|
||||
|
||||
return collectEvents(pc, "track", checkEvent);
|
||||
};
|
||||
|
||||
// comparable() - produces copy of object that is JSON comparable.
|
||||
// o = original object (required)
|
||||
// t = template of what to examine. Useful if o is non-enumerable (optional)
|
||||
|
||||
const comparable = (o, t = o) => {
|
||||
if (typeof o != 'object' || !o) {
|
||||
return o;
|
||||
}
|
||||
if (Array.isArray(t) && Array.isArray(o)) {
|
||||
return o.map((n, i) => comparable(n, t[i]));
|
||||
}
|
||||
return Object.keys(t).sort()
|
||||
.reduce((r, key) => (r[key] = comparable(o[key], t[key]), r), {});
|
||||
};
|
||||
|
||||
const stripKeyQuotes = s => s.replace(/"(\w+)":/g, "$1:");
|
||||
|
||||
const hasProps = (observed, expected) => {
|
||||
const observable = comparable(observed, expected);
|
||||
assert_equals(stripKeyQuotes(JSON.stringify(observable)),
|
||||
stripKeyQuotes(JSON.stringify(comparable(expected))));
|
||||
};
|
||||
|
||||
promise_test(async t => {
|
||||
const pc1 = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc1.close());
|
||||
const stream1 = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
||||
t.add_cleanup(() => stopTracks(stream1));
|
||||
const audio1 = stream1.getAudioTracks()[0];
|
||||
pc1.addTrack(audio1, stream1);
|
||||
const video1 = stream1.getVideoTracks()[0];
|
||||
pc1.addTrack(video1, stream1);
|
||||
|
||||
const pc2 = new RTCPeerConnection();
|
||||
t.add_cleanup(() => pc2.close());
|
||||
const stream2 = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
||||
t.add_cleanup(() => stopTracks(stream2));
|
||||
const audio2 = stream2.getAudioTracks()[0];
|
||||
pc2.addTrack(audio2, stream2);
|
||||
const video2 = stream2.getVideoTracks()[0];
|
||||
pc2.addTrack(video2, stream2);
|
||||
|
||||
const offer = await pc1.createOffer();
|
||||
|
||||
let trackEventCollector = collectTrackEvents(pc2);
|
||||
let addstreamEventCollector = collectEvents(pc2, "addstream", e => {
|
||||
hasProps(e, {stream: {id: stream1.id}});
|
||||
assert_equals(e.stream.getAudioTracks().length, 1, "One audio track");
|
||||
assert_equals(e.stream.getVideoTracks().length, 1, "One video track");
|
||||
});
|
||||
|
||||
await pc2.setRemoteDescription(offer);
|
||||
|
||||
let addstreamEvents = addstreamEventCollector.finish();
|
||||
assert_equals(addstreamEvents.length, 1, "Should have 1 addstream event");
|
||||
|
||||
let trackEvents = trackEventCollector.finish();
|
||||
|
||||
hasProps(trackEvents,
|
||||
[
|
||||
{streams: [addstreamEvents[0].stream]},
|
||||
{streams: [addstreamEvents[0].stream]}
|
||||
]);
|
||||
|
||||
await pc1.setLocalDescription(offer);
|
||||
const answer = await pc2.createAnswer();
|
||||
|
||||
trackEventCollector = collectTrackEvents(pc1);
|
||||
addstreamEventCollector = collectEvents(pc1, "addstream", e => {
|
||||
hasProps(e, {stream: {id: stream2.id}});
|
||||
assert_equals(e.stream.getAudioTracks().length, 1, "One audio track");
|
||||
assert_equals(e.stream.getVideoTracks().length, 1, "One video track");
|
||||
});
|
||||
|
||||
await pc1.setRemoteDescription(answer);
|
||||
addstreamEvents = addstreamEventCollector.finish();
|
||||
assert_equals(addstreamEvents.length, 1, "Should have 1 addstream event");
|
||||
|
||||
trackEvents = trackEventCollector.finish();
|
||||
|
||||
hasProps(trackEvents,
|
||||
[
|
||||
{streams: [addstreamEvents[0].stream]},
|
||||
{streams: [addstreamEvents[0].stream]}
|
||||
]);
|
||||
},"Check onaddstream");
|
||||
</script>
|
|
@ -17,6 +17,7 @@ This test uses the legacy callback API with no media, and thus does not require
|
|||
<!-- These files are in place when executing on W3C. -->
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/webrtc/RTCPeerConnection-helper.js"></script>
|
||||
<script type="text/javascript">
|
||||
var test = async_test('Can set up a basic WebRTC call with no data.');
|
||||
|
||||
|
@ -123,9 +124,7 @@ This test uses the legacy callback API with no media, and thus does not require
|
|||
gSecondConnection.onicecandidate = onIceCandidateToSecond;
|
||||
gSecondConnection.oniceconnectionstatechange = onIceConnectionStateChange;
|
||||
|
||||
// The offerToReceiveVideo is necessary and sufficient to make
|
||||
// an actual connection.
|
||||
gFirstConnection.createOffer({offerToReceiveVideo: true})
|
||||
generateVideoReceiveOnlyOffer(gFirstConnection)
|
||||
.then(onOfferCreated, failed('createOffer'));
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>RTCPeerConnection.prototype.createOffer</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../RTCPeerConnection-helper.js"></script>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
// Tests for the construction of initial offers according to
|
||||
// draft-ietf-rtcweb-jsep-24 section 5.2.1
|
||||
promise_test(async t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
const offer = await generateVideoReceiveOnlyOffer(pc);
|
||||
let offer_lines = offer.sdp.split('\r\n');
|
||||
// The first 3 lines are dictated by JSEP.
|
||||
assert_equals(offer_lines[0], "v=0");
|
||||
assert_equals(offer_lines[1].slice(0, 2), "o=");
|
||||
// JSEP says that the address part SHOULD be a meaningless address
|
||||
// "such as" IN IP4 127.0.0.1. We do strict matching here in order
|
||||
// to detect if anyone ever uses something different.
|
||||
assert_regexp_match(offer_lines[1], /^o=- \d+ \d+ IN IP4 127.0.0.1$/);
|
||||
const fields = RegExp(/^o=- (\d+) (\d+)/).exec(offer_lines[1]);
|
||||
// Per RFC 3264, the sess-id should be representable in an uint64
|
||||
// Note: JSEP -24 has this wrong - see bug:
|
||||
// https://github.com/rtcweb-wg/jsep/issues/855
|
||||
assert_less_than(Number(fields[1]), 2**64);
|
||||
// Per RFC 3264, the version should be less than 2^62 to avoid overflow
|
||||
assert_less_than(Number(fields[2]), 2**62);
|
||||
// Note: using - in s=- is a SHOULD in JSEP, not a MUST.
|
||||
assert_equals(offer_lines[2], "s=-");
|
||||
// After this, the order is not dictated by JSEP.
|
||||
// TODO: Check lines subsequent to the s= line.
|
||||
}, 'Offer conforms to basic SDP requirements');
|
||||
</script>
|
|
@ -21,7 +21,7 @@
|
|||
// Section 5: Browsers MUST implement VP8 and H.264 Constrained Baseline
|
||||
promise_test(async t => {
|
||||
const pc = new RTCPeerConnection();
|
||||
const offer = await pc.createOffer({offerToReceiveVideo: true});
|
||||
const offer = await generateVideoReceiveOnlyOffer(pc);
|
||||
let video_section_found = false;
|
||||
for (let section of offer.sdp.split(/\r\nm=/)) {
|
||||
if (section.search('video') != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue