| Index: content/test/data/media/peerconnection-setAndGetConfiguration.html
|
| diff --git a/content/test/data/media/peerconnection-setConfiguration.html b/content/test/data/media/peerconnection-setAndGetConfiguration.html
|
| similarity index 57%
|
| rename from content/test/data/media/peerconnection-setConfiguration.html
|
| rename to content/test/data/media/peerconnection-setAndGetConfiguration.html
|
| index 9bf30de1e0555fc5129f80b3643eee7bbaf0c37a..ac04fdf82bb92d9be7355f9bcc74316fc7dfe96e 100644
|
| --- a/content/test/data/media/peerconnection-setConfiguration.html
|
| +++ b/content/test/data/media/peerconnection-setAndGetConfiguration.html
|
| @@ -15,31 +15,46 @@
|
|
|
| var gPeerConnection = null;
|
| var gCertificate = null;
|
| + var retrievedCertificate = null;
|
| + var gRtcConfig = null;
|
|
|
| // This test creates and sets three offers, calling setConfiguration in
|
| // between each offer, expecting an ICE restart to be triggered by the next
|
| // offer.
|
| - function testSetConfiguration() {
|
| - gPeerConnection = new RTCPeerConnection(
|
| - {iceServers:[], iceTransportPolicy:'all', bundlePolicy:'balanced',
|
| - rtcpMuxPolicy:'require', certificates:[]});
|
| - // Now test successful cases of setConfiguration. Changes should trigger an
|
| - // ICE restart in the next offer. To do this, first we need to trigger an
|
| - // initial ICE gathering phase and wait until it completes.
|
| - // TODO(deadbeef): Once onicegatheringstatechange is implemented, use that
|
| - // instead of a "null" candidate.
|
| - gPeerConnection.onicecandidate = iceCandidateCallback1;
|
| - createOfferAndSetLocalDescription();
|
| + function testSetAndGetConfiguration() {
|
| + RTCPeerConnection.generateCertificate({ name:'ECDSA', namedCurve:'P-256' })
|
| + .then(function(cert) {
|
| + gRtcConfig =
|
| + {iceServers:[], iceTransportPolicy:'all', bundlePolicy:'balanced',
|
| + rtcpMuxPolicy:'require', certificates:[cert]};
|
| + gPeerConnection = new RTCPeerConnection(gRtcConfig);
|
| + // Now test successful cases of setConfiguration. Changes should trigger an
|
| + // ICE restart in the next offer. To do this, first we need to trigger an
|
| + // initial ICE gathering phase and wait until it completes.
|
| + // TODO(deadbeef): Once onicegatheringstatechange is implemented, use that
|
| + // instead of a "null" candidate.
|
| + gPeerConnection.onicecandidate = iceCandidateCallback1;
|
| + createOfferAndSetLocalDescription();
|
| + var retrievedRtcConfig = gPeerConnection.getConfiguration();
|
| + assertRtcConfigEquals(gRtcConfig, retrievedRtcConfig);
|
| + // Tests that the certificates can be successfully retrieved using
|
| + // getConfiguration() by re-applying the retrieved certification to the
|
| + // peerconnection.
|
| + assertEquals(1, retrievedRtcConfig['certificates'].length)
|
| + retrievedCertificate = gPeerConnection.getConfiguration()['certificates'][0];
|
| + });
|
| }
|
|
|
| function iceCandidateCallback1(candidate) {
|
| if (gPeerConnection.iceGatheringState === 'complete') {
|
| gPeerConnection.onicecandidate = iceCandidateCallback2;
|
| // Policy changed.
|
| - gPeerConnection.setConfiguration(
|
| + gRtcConfig =
|
| {iceServers:[], iceTransportPolicy:'relay', bundlePolicy:'balanced',
|
| - rtcpMuxPolicy:'require', certificates:[]});
|
| + rtcpMuxPolicy:'require', certificates:[retrievedCertificate]};
|
| + gPeerConnection.setConfiguration(gRtcConfig);
|
| createOfferAndSetLocalDescription();
|
| + assertRtcConfigEquals(gRtcConfig, gPeerConnection.getConfiguration());
|
| }
|
| }
|
|
|
| @@ -47,10 +62,31 @@
|
| if (gPeerConnection.iceGatheringState === 'complete') {
|
| gPeerConnection.onicecandidate = iceCandidateCallback3;
|
| // Servers changed.
|
| - gPeerConnection.setConfiguration(
|
| - {iceServers:[{urls:'stun:foo.invalid'}], iceTransportPolicy:'all',
|
| - bundlePolicy:'balanced', rtcpMuxPolicy:'require', certificates:[]});
|
| + gRtcConfig = {
|
| + iceServers:[
|
| + {
|
| + 'urls': ['stun:stun.invalid.scom:19302',
|
| + 'stun:stun.invalid2.scom:19302']
|
| + },
|
| + {
|
| + 'urls': ['turn:turn.invalid.udp?transport=udp'],
|
| + 'credential': 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
| + 'username': '28224511:1379330808'
|
| + },
|
| + {
|
| + 'urls': ['turn:turn.invalid.tcp?transport=tcp'],
|
| + 'credential': 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
| + 'username': '28224511:1379330808'
|
| + }
|
| + ],
|
| + iceTransportPolicy:'all',
|
| + bundlePolicy:'balanced',
|
| + rtcpMuxPolicy:'require',
|
| + certificates:[retrievedCertificate]
|
| + };
|
| + gPeerConnection.setConfiguration(gRtcConfig);
|
| createOfferAndSetLocalDescription();
|
| + assertRtcConfigEquals(gRtcConfig, gPeerConnection.getConfiguration());
|
| }
|
| }
|
|
|
| @@ -121,6 +157,38 @@
|
| }
|
| }
|
|
|
| + function assertRtcConfigEquals(config1, config2) {
|
| + assertEquals(config1['iceTransportPolicy'], config2['iceTransportPolicy']);
|
| + assertEquals(config1['bundlePolicy'], config2['bundlePolicy']);
|
| + assertEquals(config1['rtcpMuxPolicy'], config2['rtcpMuxPolicy']);
|
| + assertEquals(config1['iceServers'].length, config2['iceServers'].length);
|
| + for (var i in config1['iceServers']) {
|
| + var server1 = config1['iceServers'][i];
|
| + var server2 = config2['iceServers'][i];
|
| +
|
| + if (!('username' in server1)) {
|
| + assertEquals("", server2['username']);
|
| + } else {
|
| + assertEquals(server1['username'], server2['username']);
|
| + }
|
| +
|
| + if (!('credential' in server1)) {
|
| + assertEquals("", server2['credential']);
|
| + } else {
|
| + assertEquals(server1['credential'], server2['credential']);
|
| + }
|
| +
|
| + if (!('urls' in server1)) {
|
| + assertEquals(0, server2['urls'].length);
|
| + } else {
|
| + assertEquals(server1['urls'].length, server2['urls'].length);
|
| + for (var j in server1['urls']) {
|
| + assertEquals(server1['urls'][j], server2['urls'][j]);
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| // Helper function to create and apply offer.
|
| function createOfferAndSetLocalDescription() {
|
| gPeerConnection.createOffer({offerToReceiveAudio:1})
|
|
|