blob: df3de0073f09350af126242165393391a955d88f [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Tests RTCPeerConnection in have-remote-pranswer state.");
var pc = null;
function requestSucceeded4()
{
testPassed('setRemoteDescription succeeded.');
check("offer", "local", "answer", "remote", '"stable"');
finishJSTest();
}
function requestFailed4(reason)
{
errorReason = reason;
testPassed('setLocalDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
}
function requestFailed3(reason)
{
errorReason = reason;
testPassed('setLocalDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
}
function requestFailed2(reason)
{
errorReason = reason;
testPassed('setLocalDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
}
function requestFailed1(reason)
{
errorReason = reason;
testPassed('setRemoteDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
}
function requestSucceeded3()
{
testPassed('setRemoteDescription succeeded.');
check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
}
function requestSucceeded2()
{
testPassed('setRemoteDescription succeeded.');
check("offer", "local", "pranswer", "remote", '"have-remote-pranswer"');
sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
}
function requestSucceeded1()
{
testPassed('setLocalDescription succeeded.');
check("offer", "local", "", "", '"have-local-offer"');
sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded2, finishIfFailed);');
}
function finishIfSucceeded()
{
testFailed('setRemoteDescription succeeded.');
finishJSTest();
}
function finishIfFailed()
{
testFailed('setRemoteDescription failed.');
finishJSTest();
}
function check(localType, localSdp, remoteType, remoteSdp, signalingState)
{
if (localType !== "" && localSdp !== "") {
shouldBeEqualToString('pc.localDescription.type', localType);
shouldBeEqualToString('pc.localDescription.sdp', localSdp);
}
if (remoteType !== "" && remoteSdp !== "") {
shouldBeEqualToString('pc.remoteDescription.type', remoteType);
shouldBeEqualToString('pc.remoteDescription.sdp', remoteSdp);
}
shouldBe('pc.signalingState', signalingState);
}
pc = new RTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});
shouldBe('pc.signalingState', '"stable"');
var sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>