OLD | NEW |
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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (gDefaultVideoCodec !== defaultVideoCodec) { | 239 if (gDefaultVideoCodec !== defaultVideoCodec) { |
240 failure('verifyDefaultCodecs', | 240 failure('verifyDefaultCodecs', |
241 'Expected default video codec ' + gDefaultVideoCodec + | 241 'Expected default video codec ' + gDefaultVideoCodec + |
242 ', got ' + defaultVideoCodec + '.'); | 242 ', got ' + defaultVideoCodec + '.'); |
243 } | 243 } |
244 } | 244 } |
245 returnToTest('ok-verified'); | 245 returnToTest('ok-verified'); |
246 } | 246 } |
247 | 247 |
248 /** | 248 /** |
| 249 * Verifies that the peer connection's local description contains one of |
| 250 * |certificate|'s fingerprints. |
| 251 * |
| 252 * Returns 'ok-verified' on success. |
| 253 */ |
| 254 function verifyLocalDescriptionContainsCertificate(certificate) { |
| 255 let localDescription = peerConnection_().localDescription; |
| 256 if (localDescription == null) |
| 257 throw failTest('localDescription is null.'); |
| 258 for (let i = 0; i < certificate.getFingerprints().length; ++i) { |
| 259 let fingerprintSdp = 'a=fingerprint:' + |
| 260 certificate.getFingerprints()[i].algorithm + ' ' + |
| 261 certificate.getFingerprints()[i].value.toUpperCase(); |
| 262 if (localDescription.sdp.includes(fingerprintSdp)) { |
| 263 returnToTest('ok-verified'); |
| 264 return; |
| 265 } |
| 266 } |
| 267 if (!localDescription.sdp.includes('a=fingerprint')) |
| 268 throw failTest('localDescription does not contain any fingerprints.'); |
| 269 throw failTest('Certificate fingerprint not found in localDescription.'); |
| 270 } |
| 271 |
| 272 /** |
249 * Asks this page to accept an answer generated by the peer in response to a | 273 * Asks this page to accept an answer generated by the peer in response to a |
250 * previous offer by this page | 274 * previous offer by this page |
251 * | 275 * |
252 * Returns a string ok-accepted-answer on success. | 276 * Returns a string ok-accepted-answer on success. |
253 * | 277 * |
254 * @param {!string} sessionDescJson A JSON-encoded session description of type | 278 * @param {!string} sessionDescJson A JSON-encoded session description of type |
255 * 'answer'. | 279 * 'answer'. |
256 */ | 280 */ |
257 function receiveAnswerFromPeer(sessionDescJson) { | 281 function receiveAnswerFromPeer(sessionDescJson) { |
258 answer = parseJson_(sessionDescJson); | 282 answer = parseJson_(sessionDescJson); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 function parseJson_(json) { | 521 function parseJson_(json) { |
498 // Escape since the \r\n in the SDP tend to get unescaped. | 522 // Escape since the \r\n in the SDP tend to get unescaped. |
499 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); | 523 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); |
500 try { | 524 try { |
501 return JSON.parse(jsonWithEscapedLineBreaks); | 525 return JSON.parse(jsonWithEscapedLineBreaks); |
502 } catch (exception) { | 526 } catch (exception) { |
503 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + | 527 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + |
504 exception); | 528 exception); |
505 } | 529 } |
506 } | 530 } |
OLD | NEW |