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

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: Removed if-statement Created 4 years, 7 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
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
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.
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 = null) {
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) {
38 returnToTest('ok-peerconnection-created'); 41 gPeerConnection = createPeerConnection_(null);
42 returnToTest('ok-peerconnection-created');
43 } else {
44 webkitRTCPeerConnection.generateCertificate(keygenAlgorithm).then(
45 function(certificate) {
46 if (gPeerConnection !== null) {
47 throw failTest('peer connection already set during certificate ' +
48 + 'generation.');
49 }
50 gPeerConnection = createPeerConnection_(
51 {iceServers:[], certificates:[certificate]});
52 returnToTest('ok-peerconnection-created');
53 },
54 function() {
55 failTest('Certificate generation failed. keygenAlgorithm: ' +
56 JSON.stringify(keygenAlgorithm));
57 });
58 }
39 } 59 }
40 60
41 /** 61 /**
42 * Asks this page to create a local offer. 62 * Asks this page to create a local offer.
43 * 63 *
44 * Returns a string on the format ok-(JSON encoded session description). 64 * Returns a string on the format ok-(JSON encoded session description).
45 * 65 *
46 * @param {!Object} constraints Any createOffer constraints. 66 * @param {!Object} constraints Any createOffer constraints.
47 * @param {string} videoCodec If not null, promotes the specified codec to be 67 * @param {string} videoCodec If not null, promotes the specified codec to be
48 * the default video codec, e.g. the first one in the list on the 'm=video' 68 * the default video codec, e.g. the first one in the list on the 'm=video'
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 /** 276 /**
257 * Returns 277 * Returns
258 */ 278 */
259 function hasSeenCryptoInSdp() { 279 function hasSeenCryptoInSdp() {
260 returnToTest(gHasSeenCryptoInSdp); 280 returnToTest(gHasSeenCryptoInSdp);
261 } 281 }
262 282
263 // Internals. 283 // Internals.
264 284
265 /** @private */ 285 /** @private */
266 function createPeerConnection_() { 286 function createPeerConnection_(rtcConfig) {
267 try { 287 try {
268 peerConnection = new RTCPeerConnection(null, {}); 288 peerConnection = new RTCPeerConnection(rtcConfig, {});
269 } catch (exception) { 289 } catch (exception) {
270 throw failTest('Failed to create peer connection: ' + exception); 290 throw failTest('Failed to create peer connection: ' + exception);
271 } 291 }
272 peerConnection.onaddstream = addStreamCallback_; 292 peerConnection.onaddstream = addStreamCallback_;
273 peerConnection.onremovestream = removeStreamCallback_; 293 peerConnection.onremovestream = removeStreamCallback_;
274 peerConnection.onicecandidate = iceCallback_; 294 peerConnection.onicecandidate = iceCallback_;
275 return peerConnection; 295 return peerConnection;
276 } 296 }
277 297
278 /** @private */ 298 /** @private */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 function parseJson_(json) { 340 function parseJson_(json) {
321 // Escape since the \r\n in the SDP tend to get unescaped. 341 // Escape since the \r\n in the SDP tend to get unescaped.
322 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 342 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
323 try { 343 try {
324 return JSON.parse(jsonWithEscapedLineBreaks); 344 return JSON.parse(jsonWithEscapedLineBreaks);
325 } catch (exception) { 345 } catch (exception) {
326 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 346 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
327 exception); 347 exception);
328 } 348 }
329 } 349 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698