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

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

Issue 1962673002: WebRtcBrowserTest prep-CL for IndexedDB cloning of RTCCertificate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits 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
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 32 * @param {Object} keygenAlgorithm Unless null, this is an |AlgorithmIdentifier|
33 * parameter to |RTCPeerConnection.generateCertificate|. The resulting 33 * to be used as parameter to |RTCPeerConnection.generateCertificate|. The
34 * certificate will be used by the peer connection. 34 * resulting certificate will be used by the peer connection. If null, a default
35 * certificate is generated by the |RTCPeerConnection| instead.
35 */ 36 */
36 function preparePeerConnection(keygenAlgorithm = null) { 37 function preparePeerConnection(keygenAlgorithm = null) {
37 if (gPeerConnection !== null) 38 if (gPeerConnection !== null)
38 throw failTest('creating peer connection, but we already have one.'); 39 throw failTest('Creating peer connection, but we already have one.');
39 40
40 if (keygenAlgorithm === null) { 41 if (keygenAlgorithm === null) {
41 gPeerConnection = createPeerConnection_(null); 42 gPeerConnection = createPeerConnection_(null);
42 returnToTest('ok-peerconnection-created'); 43 returnToTest('ok-peerconnection-created');
43 } else { 44 } else {
44 webkitRTCPeerConnection.generateCertificate(keygenAlgorithm).then( 45 RTCPeerConnection.generateCertificate(keygenAlgorithm).then(
45 function(certificate) { 46 function(certificate) {
46 if (gPeerConnection !== null) { 47 preparePeerConnectionWithCertificate(certificate);
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 }, 48 },
54 function() { 49 function() {
55 failTest('Certificate generation failed. keygenAlgorithm: ' + 50 failTest('Certificate generation failed. keygenAlgorithm: ' +
56 JSON.stringify(keygenAlgorithm)); 51 JSON.stringify(keygenAlgorithm));
57 }); 52 });
58 } 53 }
59 } 54 }
60 55
61 /** 56 /**
57 * Creates a peer connection. Must be called before most other public functions
58 * in this file. Alternatively, see |preparePeerConnection|.
59 * @param {!Object} certificate The |RTCCertificate| that will be used by the
60 * peer connection.
61 */
62 function preparePeerConnectionWithCertificate(certificate) {
63 if (gPeerConnection !== null)
64 throw failTest('Creating peer connection, but we already have one.');
65 gPeerConnection = createPeerConnection_(
66 {iceServers:[], certificates:[certificate]});
67 returnToTest('ok-peerconnection-created');
68 }
69
70 /**
62 * Asks this page to create a local offer. 71 * Asks this page to create a local offer.
63 * 72 *
64 * Returns a string on the format ok-(JSON encoded session description). 73 * Returns a string on the format ok-(JSON encoded session description).
65 * 74 *
66 * @param {!Object} constraints Any createOffer constraints. 75 * @param {!Object} constraints Any createOffer constraints.
67 * @param {string} videoCodec If not null, promotes the specified codec to be 76 * @param {string} videoCodec If not null, promotes the specified codec to be
68 * the default video codec, e.g. the first one in the list on the 'm=video' 77 * the default video codec, e.g. the first one in the list on the 'm=video'
69 * SDP offer line. |videoCodec| is the case-sensitive codec name, e.g. 78 * SDP offer line. |videoCodec| is the case-sensitive codec name, e.g.
70 * 'VP8' or 'H264'. 79 * 'VP8' or 'H264'.
71 */ 80 */
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 function parseJson_(json) { 349 function parseJson_(json) {
341 // Escape since the \r\n in the SDP tend to get unescaped. 350 // Escape since the \r\n in the SDP tend to get unescaped.
342 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 351 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
343 try { 352 try {
344 return JSON.parse(jsonWithEscapedLineBreaks); 353 return JSON.parse(jsonWithEscapedLineBreaks);
345 } catch (exception) { 354 } catch (exception) {
346 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 355 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
347 exception); 356 exception);
348 } 357 }
349 } 358 }
OLDNEW
« no previous file with comments | « chrome/test/data/webrtc/indexeddb.js ('k') | chrome/test/data/webrtc/webrtc_audio_quality_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698