blob: baacd7bd4f4eaef48896da856a51991707069569 [file] [log] [blame]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing basic video exchange from offerer to receiver</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>
if (window.testRunner)
testRunner.setUserMediaPermission(true);
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');
}
promise_test((test) => {
var localConnection = new RTCPeerConnection();
var remoteConnection = new RTCPeerConnection();
var currentSDP;
return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
localConnection.addTrack(stream.getVideoTracks()[0], stream);
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);
assert_equals(localConnection.currentLocalDescription, null, "test 1");
assert_equals(sdpWithoutCandidate(localConnection.pendingLocalDescription.sdp), sdpWithoutCandidate(currentSDP), "test 2");
assert_equals(sdpWithoutCandidate(localConnection.localDescription.sdp), sdpWithoutCandidate(currentSDP), "test 3");
assert_equals(remoteConnection.currentRemoteDescription, null);
assert_equals(remoteConnection.pendingRemoteDescription.sdp, currentSDP, "test 4");
assert_equals(remoteConnection.remoteDescription.sdp, currentSDP, "test 5");
return Promise.all([localDescriptionPromise, remoteDescriptionPromise]);
}).then(() => {
return remoteConnection.createAnswer();
}).then((desc) => {
assert_equals(localConnection.currentLocalDescription, null);
assert_equals(localConnection.localDescription.sdp, localConnection.pendingLocalDescription.sdp, "test 7");
localConnection.setRemoteDescription(desc);
assert_equals(localConnection.currentLocalDescription.sdp, localConnection.localDescription.sdp, "test 8");
assert_equals(localConnection.pendingLocalDescription, null);
assert_equals(remoteConnection.currentRemoteDescription, null);
assert_equals(remoteConnection.pendingRemoteDescription.sdp, remoteConnection.remoteDescription.sdp, "test 10");
promise = remoteConnection.setLocalDescription(desc);
assert_equals(remoteConnection.pendingRemoteDescription, null);
return promise;
}).then(() => {
desc = remoteConnection.currentRemoteDescription;
localConnection.createDataChannel("test");
assert_equals(localConnection.currentLocalDescription.sdp, localConnection.localDescription.sdp, "test 14");
assert_equals(localConnection.pendingLocalDescription, null);
assert_equals(remoteConnection.currentRemoteDescription.sdp, remoteConnection.remoteDescription.sdp, "test 16");
assert_equals(remoteConnection.pendingRemoteDescription, null);
});
}, "description getters when changing description from video to video & data channel");
</script>
</body>
</html>