blob: 4825bd4807e4548fa15e1a552f4971b807ee15fb [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-local-pranswer state.");
var pc = null;
function requestSucceeded4()
{
testPassed('setLocalDescription succeeded.');
check("answer", "local", "offer", "remote", '"stable"');
finishJSTest();
}
function requestFailed4(reason)
{
errorReason = reason;
testPassed('setRemoteDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
sessionDescription = new RTCSessionDescription({type:"answer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded4, finishIfFailed);');
}
function requestFailed3(reason)
{
errorReason = reason;
testPassed('setRemoteDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed4);');
}
function requestFailed2(reason)
{
errorReason = reason;
testPassed('setRemoteDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
sessionDescription = new RTCSessionDescription({type:"answer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed3);');
}
function requestFailed1(reason)
{
errorReason = reason;
testPassed('setLocalDescription failed.');
shouldBe('errorReason.name', '"InvalidSessionDescriptionError"');
check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
sessionDescription = new RTCSessionDescription({type:"offer", sdp:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, finishIfSucceeded, requestFailed2);');
}
function requestSucceeded3()
{
testPassed('setLocalDescription succeeded.');
check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
sessionDescription = new RTCSessionDescription({type:"offer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, finishIfSucceeded, requestFailed1);');
}
function requestSucceeded2()
{
testPassed('setLocalDescription succeeded.');
check("pranswer", "local", "offer", "remote", '"have-local-pranswer"');
sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(sessionDescription, requestSucceeded3, finishIfFailed);');
}
function requestSucceeded1()
{
testPassed('setRemoteDescription succeeded.');
check("", "", "offer", "remote", '"have-remote-offer"');
sessionDescription = new RTCSessionDescription({type:"pranswer", sdp:"local"});
shouldNotThrow('pc.setLocalDescription(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:"remote"});
shouldNotThrow('pc.setRemoteDescription(sessionDescription, requestSucceeded1, finishIfFailed);');
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>