Chromium Code Reviews| Index: chrome/test/data/webrtc/peerconnection.js |
| diff --git a/chrome/test/data/webrtc/peerconnection.js b/chrome/test/data/webrtc/peerconnection.js |
| index adcb475b24d13c485e7ba406899e95ddc362f6eb..625a7f7e23ccdc545fd2c32dd3811ccd2f91bffd 100644 |
| --- a/chrome/test/data/webrtc/peerconnection.js |
| +++ b/chrome/test/data/webrtc/peerconnection.js |
| @@ -28,13 +28,41 @@ var gHasSeenCryptoInSdp = 'no-crypto-seen'; |
| /** |
| * Creates a peer connection. Must be called before most other public functions |
| - * in this file. |
| + * in this file. Alternatively, see: |preparePeerConnectionWithCertificate|. |
| + * @param {Object} keygenAlgorithm An |AlgorithmIdentifier| to be used as |
| + * parameter to |RTCPeerConnection.generateCertificate|. The resulting |
| + * certificate will be used by the peer connection. |
| */ |
| -function preparePeerConnection() { |
| +function preparePeerConnection(keygenAlgorithm) { |
| if (gPeerConnection != null) |
| throw failTest('creating peer connection, but we already have one.'); |
| - gPeerConnection = createPeerConnection_(); |
| + if (keygenAlgorithm == null) { |
|
jansson
2016/04/27 07:07:30
It's deemed best practice to use the strict equali
hbos_chromium
2016/04/27 11:19:03
Done. Also updated gPeerConnection comparison.
|
| + gPeerConnection = createPeerConnection_(null); |
| + returnToTest('ok-peerconnection-created'); |
| + } else { |
| + webkitRTCPeerConnection.generateCertificate(keygenAlgorithm).then( |
| + function(certificate) { |
| + preparePeerConnectionWithCertificate(certificate); |
| + }, |
| + function() { |
| + failTest('Certificate generation failed. keygenAlgorithm: ' + |
| + JSON.stringify(keygenAlgorithm)); |
| + }); |
| + } |
| +} |
| + |
| +/** |
| + * Creates a peer connection. Must be called before most other public functions |
| + * in this file. Alternatively, see: |preparePeerConnection|. |
| + * @param {!Object} certificate The |RTCCertificate| that will be used by the |
| + * peer connection. |
| + */ |
| +function preparePeerConnectionWithCertificate(certificate) { |
|
phoglund_chromium
2016/04/26 11:54:20
There's no need to make this "public" in the javas
hbos_chromium
2016/04/27 11:19:03
It's not used but I was planning on probably using
phoglund_chromium
2016/04/27 13:23:12
Yes, do it in the later CL in that case.
|
| + if (gPeerConnection != null) |
| + throw failTest('creating peer connection, but we already have one.'); |
| + gPeerConnection = createPeerConnection_( |
| + {iceServers:[], certificates:[certificate]}); |
| returnToTest('ok-peerconnection-created'); |
| } |
| @@ -263,9 +291,9 @@ function hasSeenCryptoInSdp() { |
| // Internals. |
| /** @private */ |
| -function createPeerConnection_() { |
| +function createPeerConnection_(rtcConfig) { |
| try { |
| - peerConnection = new RTCPeerConnection(null, {}); |
| + peerConnection = new RTCPeerConnection(rtcConfig, {}); |
| } catch (exception) { |
| throw failTest('Failed to create peer connection: ' + exception); |
| } |