blob: 805b39f892e65eeb41405c32a59012a1f21c103b [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);
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(localConnection.pendingLocalDescription.sdp, currentSDP, "test 2");
assert_equals(localConnection.localDescription.sdp, 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>