2017-03-07 17:15:06 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Testing basic video exchange from offerer to receiver</title>
|
2017-03-08 17:10:12 +00:00
|
|
|
<script src="../../resources/testharness.js"></script>
|
|
|
|
<script src="../../resources/testharnessreport.js"></script>
|
2017-03-07 17:15:06 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<script>
|
|
|
|
if (window.testRunner)
|
|
|
|
testRunner.setUserMediaPermission(true);
|
|
|
|
|
2020-05-06 14:15:11 +00:00
|
|
|
|
|
|
|
function sdpWithoutCandidate(sdp)
|
|
|
|
{
|
|
|
|
return sdp.split('\r\n').filter(line => {
|
|
|
|
return line.indexOf('a=candidate') !== 0 && line.indexOf('c=IN IP4') !== 0 && line.indexOf('m=video') !== 0 && line.indexOf('m=audio') !== 0;
|
|
|
|
}).join('\r\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-07 17:15:06 +00:00
|
|
|
promise_test((test) => {
|
|
|
|
var localConnection = new RTCPeerConnection();
|
|
|
|
var remoteConnection = new RTCPeerConnection();
|
|
|
|
var currentSDP;
|
|
|
|
return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
|
|
|
|
|
2017-04-11 22:47:26 +00:00
|
|
|
localConnection.addTrack(stream.getVideoTracks()[0], stream);
|
2017-03-07 17:15:06 +00:00
|
|
|
return localConnection.createOffer();
|
|
|
|
}).then((desc) => {
|
|
|
|
currentSDP = desc.sdp;
|
|
|
|
|
|
|
|
assert_equals(localConnection.currentLocalDescription, null);
|
|
|
|
assert_equals(localConnection.pendingLocalDescription, null);
|
|
|
|
assert_equals(localConnection.localDescription, null);
|
|
|
|
|
|
|
|
assert_equals(remoteConnection.currentRemoteDescription, null);
|
|
|
|
assert_equals(remoteConnection.pendingRemoteDescription, null);
|
|
|
|
assert_equals(remoteConnection.remoteDescription, null);
|
|
|
|
|
|
|
|
localDescriptionPromise = localConnection.setLocalDescription(desc);
|
|
|
|
remoteDescriptionPromise = remoteConnection.setRemoteDescription(desc);
|
|
|
|
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(localConnection.currentLocalDescription, null, "test 1");
|
2020-05-06 14:15:11 +00:00
|
|
|
assert_equals(sdpWithoutCandidate(localConnection.pendingLocalDescription.sdp), sdpWithoutCandidate(currentSDP), "test 2");
|
|
|
|
assert_equals(sdpWithoutCandidate(localConnection.localDescription.sdp), sdpWithoutCandidate(currentSDP), "test 3");
|
2017-03-07 17:15:06 +00:00
|
|
|
|
|
|
|
assert_equals(remoteConnection.currentRemoteDescription, null);
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(remoteConnection.pendingRemoteDescription.sdp, currentSDP, "test 4");
|
|
|
|
assert_equals(remoteConnection.remoteDescription.sdp, currentSDP, "test 5");
|
2017-03-07 17:15:06 +00:00
|
|
|
|
|
|
|
return Promise.all([localDescriptionPromise, remoteDescriptionPromise]);
|
|
|
|
}).then(() => {
|
|
|
|
return remoteConnection.createAnswer();
|
2017-04-07 15:24:09 +00:00
|
|
|
}).then((desc) => {
|
2017-03-07 17:15:06 +00:00
|
|
|
assert_equals(localConnection.currentLocalDescription, null);
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(localConnection.localDescription.sdp, localConnection.pendingLocalDescription.sdp, "test 7");
|
2017-03-07 17:15:06 +00:00
|
|
|
|
|
|
|
localConnection.setRemoteDescription(desc);
|
|
|
|
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(localConnection.currentLocalDescription.sdp, localConnection.localDescription.sdp, "test 8");
|
2017-03-07 17:15:06 +00:00
|
|
|
assert_equals(localConnection.pendingLocalDescription, null);
|
|
|
|
|
|
|
|
assert_equals(remoteConnection.currentRemoteDescription, null);
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(remoteConnection.pendingRemoteDescription.sdp, remoteConnection.remoteDescription.sdp, "test 10");
|
2017-03-07 17:15:06 +00:00
|
|
|
|
2017-04-07 15:24:09 +00:00
|
|
|
promise = remoteConnection.setLocalDescription(desc);
|
2017-03-07 17:15:06 +00:00
|
|
|
|
|
|
|
assert_equals(remoteConnection.pendingRemoteDescription, null);
|
2017-04-07 15:24:09 +00:00
|
|
|
return promise;
|
|
|
|
}).then(() => {
|
|
|
|
desc = remoteConnection.currentRemoteDescription;
|
2017-03-07 17:15:06 +00:00
|
|
|
|
|
|
|
localConnection.createDataChannel("test");
|
|
|
|
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(localConnection.currentLocalDescription.sdp, localConnection.localDescription.sdp, "test 14");
|
2017-03-07 17:15:06 +00:00
|
|
|
assert_equals(localConnection.pendingLocalDescription, null);
|
|
|
|
|
2017-04-07 15:24:09 +00:00
|
|
|
assert_equals(remoteConnection.currentRemoteDescription.sdp, remoteConnection.remoteDescription.sdp, "test 16");
|
2017-03-07 17:15:06 +00:00
|
|
|
assert_equals(remoteConnection.pendingRemoteDescription, null);
|
|
|
|
});
|
|
|
|
}, "description getters when changing description from video to video & data channel");
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|