blob: 2624d778851a9ee3a02b50aa6002ffa7e3550283 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script>
description("Tests the RTCPeerConnection constructor.");
shouldNotThrow("new webkitRTCPeerConnection(null);");
shouldNotThrow("new webkitRTCPeerConnection(undefined);");
shouldThrow("new webkitRTCPeerConnection();");
shouldThrow("new webkitRTCPeerConnection('');");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'stun:foo.com'}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', credential:'x'},{url:'stun:bar.com'}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com', 'turn:foo.com']}]});");
shouldThrow("new webkitRTCPeerConnection({fooServers:[]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:true});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[{url:'foo'}]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[{urls:[1, 'turn:foo.com']}]});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'none'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'relay'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'all'});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'foo'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'balanced'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-bundle'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-compat'});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'foo'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'negotiate'});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'require'});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'foo'});");
// Deprecated.
shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1}});");
shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:1, valid_and_supported_2:1}});");
shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0}]});");
shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0},{valid_and_supported_2:0}]});");
shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_but_unsupported_1:0},{valid_but_unsupported_2:0}]});");
shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1:66}});");
shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{invalid:1}});");
shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1}});");
shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported_1:1, valid_and_supported_1:1}});");
shouldThrow("new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:0}});");
shouldThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1:0,valid_and_supported_2:0}]});");
// Optional constraints are ignored even if they are invalid.
shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{invalid:0}]});");
shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_1:1});");
shouldThrow("new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1});");
shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandatory:{valid_and_supported_1:1}});");
// Construct with certificates.
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:null});");
shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[null]});");
shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[1337]});");
// Global certificate variables so that the "should..." methods can evaluate them.
var certRSA = null;
var certECDSA = null;
function testCertificates1RSA()
{
webkitRTCPeerConnection.generateCertificate({ name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" })
.then(function(certificate) {
certRSA = certificate;
shouldNotThrow('new webkitRTCPeerConnection({iceServers:[], certificates:[certRSA]}, null);');
testCertificates2ECDSA();
},
function() {
testFailed('Generating RSA 2048');
testCertificates2ECDSA();
});
}
function testCertificates2ECDSA()
{
webkitRTCPeerConnection.generateCertificate({ name: "ECDSA", namedCurve: "P-256" })
.then(function(certificate) {
certECDSA = certificate;
shouldNotThrow('new webkitRTCPeerConnection({iceServers:[], certificates:[certECDSA]}, null);');
finishJSTest();
},
function() {
testFailed('Generating ECDSA P-256');
finishJSTest();
});
}
// Sequentially test construction with RSA and ECDSA certificates.
// testCertificates2ECDSA's callback methods mark the end of the async tests.
testCertificates1RSA();
window.jsTestIsAsync = true;
window.successfullyParsed = true;
</script>
</body>
</html>