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

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

Issue 2677233002: Expose RTCPeerConnection.icegatheringstatechange. (Closed)
Patch Set: fix number of passing tests Created 3 years, 9 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 */
11 var gPeerConnection = null; 11 var gPeerConnection = null;
12 12
13 /** 13 /**
14 * This stores ICE candidates generated on this side. 14 * This stores ICE candidates generated on this side.
15 * @private 15 * @private
16 */ 16 */
17 var gIceCandidates = []; 17 var gIceCandidates = [];
18 18
19 /** 19 /**
20 * This stores last ICE gathering state emitted on this side.
21 * @private
22 */
23 var gIceGatheringState = 'no-gathering-state';
24
25 /**
20 * Keeps track of whether we have seen crypto information in the SDP. 26 * Keeps track of whether we have seen crypto information in the SDP.
21 * @private 27 * @private
22 */ 28 */
23 var gHasSeenCryptoInSdp = 'no-crypto-seen'; 29 var gHasSeenCryptoInSdp = 'no-crypto-seen';
24 30
25 /** 31 /**
26 * The default audio codec that should be used when creating an offer. 32 * The default audio codec that should be used when creating an offer.
27 * @private 33 * @private
28 */ 34 */
29 var gDefaultAudioCodec = null; 35 var gDefaultAudioCodec = null;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 */ 416 */
411 function measureGetStatsCallbackPerformance() { 417 function measureGetStatsCallbackPerformance() {
412 let t0 = performance.now(); 418 let t0 = performance.now();
413 peerConnection_().getStats( 419 peerConnection_().getStats(
414 function(response) { 420 function(response) {
415 let t1 = performance.now(); 421 let t1 = performance.now();
416 returnToTest('ok-' + (t1 - t0)); 422 returnToTest('ok-' + (t1 - t0));
417 }); 423 });
418 } 424 }
419 425
426 /**
427 * Returns the last iceGatheringState emitted from icegatheringstatechange.
428 */
429 function getLastGatheringState() {
430 returnToTest(gIceGatheringState);
431 }
432
420 // Internals. 433 // Internals.
421 434
422 /** @private */ 435 /** @private */
423 function createPeerConnection_(rtcConfig) { 436 function createPeerConnection_(rtcConfig) {
424 try { 437 try {
425 peerConnection = new RTCPeerConnection(rtcConfig, {}); 438 peerConnection = new RTCPeerConnection(rtcConfig, {});
426 } catch (exception) { 439 } catch (exception) {
427 throw failTest('Failed to create peer connection: ' + exception); 440 throw failTest('Failed to create peer connection: ' + exception);
428 } 441 }
429 peerConnection.onaddstream = addStreamCallback_; 442 peerConnection.onaddstream = addStreamCallback_;
430 peerConnection.onremovestream = removeStreamCallback_; 443 peerConnection.onremovestream = removeStreamCallback_;
431 peerConnection.onicecandidate = iceCallback_; 444 peerConnection.onicecandidate = iceCallback_;
445 peerConnection.onicegatheringstatechange = iceGatheringCallback_;
432 return peerConnection; 446 return peerConnection;
433 } 447 }
434 448
435 /** @private */ 449 /** @private */
436 function peerConnection_() { 450 function peerConnection_() {
437 if (gPeerConnection == null) 451 if (gPeerConnection == null)
438 throw failTest('Trying to use peer connection, but none was created.'); 452 throw failTest('Trying to use peer connection, but none was created.');
439 return gPeerConnection; 453 return gPeerConnection;
440 } 454 }
441 455
442 /** @private */ 456 /** @private */
443 function iceCallback_(event) { 457 function iceCallback_(event) {
444 if (event.candidate) 458 if (event.candidate)
445 gIceCandidates.push(event.candidate); 459 gIceCandidates.push(event.candidate);
446 } 460 }
447 461
448 /** @private */ 462 /** @private */
463 function iceGatheringCallback_() {
464 gIceGatheringState = peerConnection.iceGatheringState;
465 }
466
467
468 /** @private */
449 function setLocalDescription(peerConnection, sessionDescription) { 469 function setLocalDescription(peerConnection, sessionDescription) {
450 if (sessionDescription.sdp.search('a=crypto') != -1 || 470 if (sessionDescription.sdp.search('a=crypto') != -1 ||
451 sessionDescription.sdp.search('a=fingerprint') != -1) 471 sessionDescription.sdp.search('a=fingerprint') != -1)
452 gHasSeenCryptoInSdp = 'crypto-seen'; 472 gHasSeenCryptoInSdp = 'crypto-seen';
453 473
454 peerConnection.setLocalDescription( 474 peerConnection.setLocalDescription(
455 sessionDescription, 475 sessionDescription,
456 function() { success('setLocalDescription'); }, 476 function() { success('setLocalDescription'); },
457 function(error) { failure('setLocalDescription', error); }); 477 function(error) { failure('setLocalDescription', error); });
458 } 478 }
(...skipping 18 matching lines...) Expand all
477 function parseJson_(json) { 497 function parseJson_(json) {
478 // Escape since the \r\n in the SDP tend to get unescaped. 498 // Escape since the \r\n in the SDP tend to get unescaped.
479 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n'); 499 jsonWithEscapedLineBreaks = json.replace(/\r\n/g, '\\r\\n');
480 try { 500 try {
481 return JSON.parse(jsonWithEscapedLineBreaks); 501 return JSON.parse(jsonWithEscapedLineBreaks);
482 } catch (exception) { 502 } catch (exception) {
483 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' + 503 failTest('Failed to parse JSON: ' + jsonWithEscapedLineBreaks + ', got ' +
484 exception); 504 exception);
485 } 505 }
486 } 506 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698