| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="../../resources/js-test.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <script> | |
| 8 description("Tests the RTCPeerConnection constructor."); | |
| 9 | |
| 10 shouldNotThrow("new webkitRTCPeerConnection(null);"); | |
| 11 shouldNotThrow("new webkitRTCPeerConnection(undefined);"); | |
| 12 shouldThrow("new webkitRTCPeerConnection();"); | |
| 13 shouldThrow("new webkitRTCPeerConnection('');"); | |
| 14 | |
| 15 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[]});"); | |
| 16 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'stun:foo.com'}]})
;"); | |
| 17 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', cr
edential:'x'}]});"); | |
| 18 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{url:'turn:foo.com', cr
edential:'x'},{url:'stun:bar.com'}]});"); | |
| 19 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:'stun:foo.com'}]}
);"); | |
| 20 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[{urls:['stun:foo.com',
'turn:foo.com']}]});"); | |
| 21 | |
| 22 shouldThrow("new webkitRTCPeerConnection({fooServers:[]});"); | |
| 23 shouldThrow("new webkitRTCPeerConnection({iceServers:true});"); | |
| 24 shouldThrow("new webkitRTCPeerConnection({iceServers:[1, 2, 3]});"); | |
| 25 shouldThrow("new webkitRTCPeerConnection({iceServers:[{}]});"); | |
| 26 shouldThrow("new webkitRTCPeerConnection({iceServers:[{url:'foo'}]});"); | |
| 27 shouldThrow("new webkitRTCPeerConnection({iceServers:[{urls:[1, 'turn:foo.com']}
]});"); | |
| 28 | |
| 29 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'none'
});"); | |
| 30 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'relay
'});"); | |
| 31 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'all'}
);"); | |
| 32 shouldThrow("new webkitRTCPeerConnection({iceServers:[], iceTransports:'foo'});"
); | |
| 33 | |
| 34 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'balanc
ed'});"); | |
| 35 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-bu
ndle'});"); | |
| 36 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'max-co
mpat'});"); | |
| 37 shouldThrow("new webkitRTCPeerConnection({iceServers:[], bundlePolicy:'foo'});")
; | |
| 38 | |
| 39 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'negot
iate'});"); | |
| 40 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'requi
re'});"); | |
| 41 shouldThrow("new webkitRTCPeerConnection({iceServers:[], rtcpMuxPolicy:'foo'});"
); | |
| 42 | |
| 43 // Deprecated. | |
| 44 shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supporte
d_1:1}});"); | |
| 45 shouldNotThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supporte
d_1:1, valid_and_supported_2:1}});"); | |
| 46 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supporte
d_1:0}]});"); | |
| 47 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supporte
d_1:0},{valid_and_supported_2:0}]});"); | |
| 48 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{valid_but_unsuppor
ted_1:0},{valid_but_unsupported_2:0}]});"); | |
| 49 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_and_supported_1
:66}});"); | |
| 50 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{invalid:1}});"); | |
| 51 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported
_1:1}});"); | |
| 52 shouldThrow("new webkitRTCPeerConnection(null, {mandatory:{valid_but_unsupported
_1:1, valid_and_supported_1:1}});"); | |
| 53 shouldThrow("new webkitRTCPeerConnection(null, {optional:{valid_and_supported_1:
0}});"); | |
| 54 shouldThrow("new webkitRTCPeerConnection(null, {optional:[{valid_and_supported_1
:0,valid_and_supported_2:0}]});"); | |
| 55 // Optional constraints are ignored even if they are invalid. | |
| 56 shouldNotThrow("new webkitRTCPeerConnection(null, {optional:[{invalid:0}]});"); | |
| 57 shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_1:1});"); | |
| 58 shouldThrow("new webkitRTCPeerConnection(null, {valid_but_unsupported_1:1});"); | |
| 59 shouldThrow("new webkitRTCPeerConnection(null, {valid_and_supported_2:1, mandato
ry:{valid_and_supported_1:1}});"); | |
| 60 | |
| 61 // Construct with certificates. | |
| 62 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:null});
"); | |
| 63 shouldNotThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[]});")
; | |
| 64 shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[null]});"
); | |
| 65 shouldThrow("new webkitRTCPeerConnection({iceServers:[], certificates:[1337]});"
); | |
| 66 // Global certificate variables so that the "should..." methods can evaluate the
m. | |
| 67 var certRSA = null; | |
| 68 var certECDSA = null; | |
| 69 var certExpired = null; | |
| 70 | |
| 71 function testCertificates1RSA() | |
| 72 { | |
| 73 webkitRTCPeerConnection.generateCertificate({ name: "RSASSA-PKCS1-v1_5", mod
ulusLength: 2048, publicExponent: new Uint8Array([1, 0, 1]), hash: "SHA-256" }) | |
| 74 .then(function(certificate) { | |
| 75 certRSA = certificate; | |
| 76 shouldNotThrow('new webkitRTCPeerConnection({iceServers:[], ce
rtificates:[certRSA]}, null);'); | |
| 77 testCertificates2ECDSA(); | |
| 78 }, | |
| 79 function() { | |
| 80 testFailed('Generating RSA 2048'); | |
| 81 testCertificates2ECDSA(); | |
| 82 }); | |
| 83 } | |
| 84 function testCertificates2ECDSA() | |
| 85 { | |
| 86 webkitRTCPeerConnection.generateCertificate({ name: "ECDSA", namedCurve: "P-
256" }) | |
| 87 .then(function(certificate) { | |
| 88 certECDSA = certificate; | |
| 89 shouldNotThrow('new webkitRTCPeerConnection({iceServers:[], ce
rtificates:[certECDSA]}, null);'); | |
| 90 testCertificates3Expired(); | |
| 91 }, | |
| 92 function() { | |
| 93 testFailed('Generating ECDSA P-256'); | |
| 94 testCertificates3Expired(); | |
| 95 }); | |
| 96 } | |
| 97 function testCertificates3Expired() | |
| 98 { | |
| 99 webkitRTCPeerConnection.generateCertificate({ name: "ECDSA", namedCurve: "P-
256", expires:0 }) | |
| 100 .then(function(certificate) { | |
| 101 certExpired = certificate; | |
| 102 shouldBeTrue('certExpired.expires <= new Date().getTime()'); | |
| 103 shouldThrow('new webkitRTCPeerConnection({iceServers:[], certi
ficates:[certExpired]}, null);'); | |
| 104 finishJSTest(); | |
| 105 }, | |
| 106 function() { | |
| 107 testFailed('Generating ECDSA P-256'); | |
| 108 finishJSTest(); | |
| 109 }); | |
| 110 } | |
| 111 // Sequentially test construction with RSA and ECDSA certificates. | |
| 112 // testCertificates3Expired's callback methods mark the end of the async tests. | |
| 113 testCertificates1RSA(); | |
| 114 | |
| 115 window.jsTestIsAsync = true; | |
| 116 window.successfullyParsed = true; | |
| 117 </script> | |
| 118 </body> | |
| 119 </html> | |
| OLD | NEW |