Bug 1063971 - Allow SetRemoteDescription to omit callbacks again. r=jib, a=lmandel
authorRandell Jesup <rjesup@jesup.org>
Sun, 07 Sep 2014 12:08:49 -0400
changeset 216674 880228a5208a
parent 216673 7984a6ceffb8
child 216675 776ddfd41f21
push id3870
push userryanvm@gmail.com
push date2014-09-08 17:45 +0000
treeherdermozilla-beta@880228a5208a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, lmandel
bugs1063971
milestone33.0
Bug 1063971 - Allow SetRemoteDescription to omit callbacks again. r=jib, a=lmandel
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -673,28 +673,33 @@ RTCPeerConnection.prototype = {
     }
     return good;
   },
 
   _setRemoteDescription: function(type, sdp, onSuccess, onError) {
     let idpComplete = false;
     let setRemoteComplete = false;
     let idpError = null;
+    let isDone = false;
 
     // we can run the IdP validation in parallel with setRemoteDescription this
     // complicates much more than would be ideal, but it ensures that the IdP
     // doesn't hold things up too much when it's not on the critical path
     let allDone = () => {
-      if (!setRemoteComplete || !idpComplete || !onSuccess) {
+      if (!setRemoteComplete || !idpComplete || isDone) {
         return;
       }
+      // May be null if the user didn't supply success/failure callbacks.
+      // Violation of spec, but we allow it for now
       this._remoteType = this._pendingType;
       this._pendingType = null;
+      // May be null if the user didn't supply success/failure callbacks.
+      // Violation of spec, but we allow it for now
       this.callCB(onSuccess);
-      onSuccess = null;
+      isDone = true;
       this._executeNext();
     };
 
     let setRemoteDone = () => {
       setRemoteComplete = true;
       allDone();
     };