Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: chrome/test/data/webrtc/peerconnection.js

Issue 1917133002: WebRtcBrowserTest tests with RSA and ECDSA certificates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /** 1 /**
2 * Copyright 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * The one and only peer connection in this page. 8 * The one and only peer connection in this page.
9 * @private 9 * @private
10 */ 10 */
(...skipping 10 matching lines...) Expand all
21 * @private 21 * @private
22 */ 22 */
23 var gHasSeenCryptoInSdp = 'no-crypto-seen'; 23 var gHasSeenCryptoInSdp = 'no-crypto-seen';
24 24
25 // Public interface to tests. These are expected to be called with 25 // Public interface to tests. These are expected to be called with
26 // ExecuteJavascript invocations from the browser tests and will return answers 26 // ExecuteJavascript invocations from the browser tests and will return answers
27 // through the DOM automation controller. 27 // through the DOM automation controller.
28 28
29 /** 29 /**
30 * Creates a peer connection. Must be called before most other public functions 30 * Creates a peer connection. Must be called before most other public functions
31 * in this file. 31 * in this file. Alternatively, see: |preparePeerConnectionWithCertificate|.
32 * @param {Object} keygenAlgorithm An |AlgorithmIdentifier| to be used as
33 * parameter to |RTCPeerConnection.generateCertificate|. The resulting
34 * certificate will be used by the peer connection.
32 */ 35 */
33 function preparePeerConnection() { 36 function preparePeerConnection(keygenAlgorithm) {
34 if (gPeerConnection != null) 37 if (gPeerConnection != null)
35 throw failTest('creating peer connection, but we already have one.'); 38 throw failTest('creating peer connection, but we already have one.');
36 39
37 gPeerConnection = createPeerConnection_(); 40 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.
41 gPeerConnection = createPeerConnection_(null);
42 returnToTest('ok-peerconnection-created');
43 } else {
44 webkitRTCPeerConnection.generateCertificate(keygenAlgorithm).then(
45 function(certificate) {
46 preparePeerConnectionWithCertificate(certificate);
47 },
48 function() {
49 failTest('Certificate generation failed. keygenAlgorithm: ' +
50 JSON.stringify(keygenAlgorithm));
51 });
52 }
53 }
54
55 /**
56 * Creates a peer connection. Must be called before most other public functions
57 * in this file. Alternatively, see: |preparePeerConnection|.
58 * @param {!Object} certificate The |RTCCertificate| that will be used by the
59 * peer connection.
60 */
61 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.
62 if (gPeerConnection != null)
63 throw failTest('creating peer connection, but we already have one.');
64 gPeerConnection = createPeerConnection_(
65 {iceServers:[], certificates:[certificate]});
38 returnToTest('ok-peerconnection-created'); 66 returnToTest('ok-peerconnection-created');
39 } 67 }
40 68
41 /** 69 /**
42 * Asks this page to create a local offer. 70 * Asks this page to create a local offer.
43 * 71 *
44 * Returns a string on the format ok-(JSON encoded session description). 72 * Returns a string on the format ok-(JSON encoded session description).
45 * 73 *
46 * @param {!Object} constraints Any createOffer constraints. 74 * @param {!Object} constraints Any createOffer constraints.
47 * @param {string} videoCodec If not null, promotes the specified codec to be 75 * @param {string} videoCodec If not null, promotes the specified codec to be
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 /** 284 /**
257 * Returns 285 * Returns
258 */ 286 */
259 function hasSeenCryptoInSdp() { 287 function hasSeenCryptoInSdp() {
260 returnToTest(gHasSeenCryptoInSdp); 288 returnToTest(gHasSeenCryptoInSdp);
261 } 289 }
262 290
263 // Internals. 291 // Internals.
264 292
265 /** @private */ 293 /** @private */
266 function createPeerConnection_() { 294 function createPeerConnection_(rtcConfig) {
267 try { 295 try {
268 peerConnection = new RTCPeerConnection(null, {}); 296 peerConnection = new RTCPeerConnection(rtcConfig, {});
269 } catch (exception) { 297 } catch (exception) {
270 throw failTest('Failed to create peer connection: ' + exception); 298 throw failTest('Failed to create peer connection: ' + exception);
271 } 299 }
272 peerConnection.onaddstream = addStreamCallback_; 300 peerConnection.onaddstream = addStreamCallback_;
273 peerConnection.onremovestream = removeStreamCallback_; 301 peerConnection.onremovestream = removeStreamCallback_;
274 peerConnection.onicecandidate = iceCallback_; 302 peerConnection.onicecandidate = iceCallback_;
275 return peerConnection; 303 return peerConnection;
276 } 304 }
277 305
278 /** @private */ 306 /** @private */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 function parseJson_(json) { 348 function parseJson_(json) {
321 // Escape since the \r\n in the SDP tend to get unescaped. 349 // Escape since the \r\n in the SDP tend to get unescaped.
322 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 350 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
323 try { 351 try {
324 return JSON.parse(jsonWithEscapedLineBreaks); 352 return JSON.parse(jsonWithEscapedLineBreaks);
325 } catch (exception) { 353 } catch (exception) {
326 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 354 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
327 exception); 355 exception);
328 } 356 }
329 } 357 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698