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