Backed out changeset b490b5843f3c for M2 bustage
authorRandell Jesup <rjesup@jesup.org>
Sun, 27 Oct 2013 20:45:28 -0400
changeset 166214 64d531ae16c7af209f49b31c7697ffa7aaca8522
parent 166213 b490b5843f3c708e093dfecb5f7e19e662989f4b
child 166218 33e004329f53465b9d9ef8ac097059e1fb4794de
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone27.0a1
backs outb490b5843f3c708e093dfecb5f7e19e662989f4b
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset b490b5843f3c for M2 bustage
dom/media/PeerConnection.js
dom/media/tests/mochitest/pc.js
dom/webidl/RTCPeerConnection.webidl
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -220,16 +220,20 @@ function RTCPeerConnection() {
    * has finished, we will check the queue for the next operation and execute
    * if neccesary. The _pending flag indicates whether an operation is currently
    * in progress.
    */
   this._pending = false;
 
   // States
   this._iceGatheringState = this._iceConnectionState = "new";
+
+  // Deprecated callbacks
+  this._ongatheringchange = null;
+  this._onicechange = null;
 }
 RTCPeerConnection.prototype = {
   classDescription: "mozRTCPeerConnection",
   classID: PC_CID,
   contractID: PC_CONTRACT,
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
                                          Ci.nsIDOMGlobalPropertyInitializer]),
   init: function(win) { this._win = win; },
@@ -478,32 +482,54 @@ RTCPeerConnection.prototype = {
   makeGetterSetterEH: function(name) {
     Object.defineProperty(this, name,
                           {
                             get:function()  { return this.getEH(name); },
                             set:function(h) { return this.setEH(name, h); }
                           });
   },
 
+  get onicechange()       { return this._onicechange; },
+  get ongatheringchange() { return this._ongatheringchange; },
+
+  set onicechange(cb) {
+    this.deprecated("onicechange");
+    this._onicechange = cb;
+  },
+  set ongatheringchange(cb) {
+    this.deprecated("ongatheringchange");
+    this._ongatheringchange = cb;
+  },
+
+  deprecated: function(name) {
+    this.reportWarning(name + " is deprecated!", null, 0);
+  },
+
   createOffer: function(onSuccess, onError, constraints) {
     if (!constraints) {
       constraints = {};
     }
+    if (!onError) {
+      this.deprecated("calling createOffer without failureCallback");
+    }
     this._mustValidateConstraints(constraints, "createOffer passed invalid constraints");
     this._onCreateOfferSuccess = onSuccess;
     this._onCreateOfferFailure = onError;
 
     this._queueOrRun({ func: this._createOffer, args: [constraints], wait: true });
   },
 
   _createOffer: function(constraints) {
     this._getPC().createOffer(constraints);
   },
 
   _createAnswer: function(onSuccess, onError, constraints, provisional) {
+    if (!onError) {
+      this.deprecated("calling createAnswer without failureCallback");
+    }
     this._onCreateAnswerSuccess = onSuccess;
     this._onCreateAnswerFailure = onError;
 
     if (!this.remoteDescription) {
 
       this._observer.onCreateAnswerError(Ci.IPeerConnection.kInvalidState,
                                          "setRemoteDescription not called");
       return;
@@ -664,16 +690,26 @@ RTCPeerConnection.prototype = {
     return this._getPC().getLocalStreams();
   },
 
   getRemoteStreams: function() {
     this._checkClosed();
     return this._getPC().getRemoteStreams();
   },
 
+  // Backwards-compatible attributes
+  get localStreams() {
+    this.deprecated("localStreams");
+    return this.getLocalStreams();
+  },
+  get remoteStreams() {
+    this.deprecated("remoteStreams");
+    return this.getRemoteStreams();
+  },
+
   get localDescription() {
     this._checkClosed();
     let sdp = this._getPC().localDescription;
     if (sdp.length == 0) {
       return null;
     }
     return new this._win.mozRTCSessionDescription({ type: this._localType,
                                                     sdp: sdp });
@@ -713,16 +749,45 @@ RTCPeerConnection.prototype = {
     this._iceGatheringState = state;
   },
 
   changeIceConnectionState: function(state) {
     this._iceConnectionState = state;
     this.dispatchEvent(new this._win.Event("iceconnectionstatechange"));
   },
 
+  get readyState() {
+    this.deprecated("readyState");
+    // checking for our local pc closed indication
+    // before invoking the pc methods.
+    if(this._closed) {
+      return "closed";
+    }
+
+    var state="undefined";
+    switch (this._getPC().readyState) {
+      case Ci.IPeerConnection.kNew:
+        state = "new";
+        break;
+      case Ci.IPeerConnection.kNegotiating:
+        state = "negotiating";
+        break;
+      case Ci.IPeerConnection.kActive:
+        state = "active";
+        break;
+      case Ci.IPeerConnection.kClosing:
+        state = "closing";
+        break;
+      case Ci.IPeerConnection.kClosed:
+        state = "closed";
+        break;
+    }
+    return state;
+  },
+
   getStats: function(selector, onSuccess, onError) {
     this._onGetStatsSuccess = onSuccess;
     this._onGetStatsFailure = onError;
 
     this._queueOrRun({
       func: this._getStats,
       args: [selector],
       wait: true
@@ -989,33 +1054,39 @@ PeerConnectionObserver.prototype = {
 
   handleIceStateChanges: function(iceState) {
     var histogram = Services.telemetry.getHistogramById("WEBRTC_ICE_SUCCESS_RATE");
 
     const STATE_MAP = {
       IceGathering:
         { gathering: "gathering" },
       IceWaiting:
-        { connection: "new",  gathering: "complete" },
+        { connection: "new",  gathering: "complete", legacy: "starting" },
       IceChecking:
-        { connection: "checking" },
+        { connection: "checking", legacy: "checking" },
       IceConnected:
-        { connection: "connected", success: true },
+        { connection: "connected", legacy: "connected", success: true },
       IceFailed:
-        { connection: "failed", success: false }
+        { connection: "failed", legacy: "failed", success: false }
     };
     // These are all the allowed inputs.
 
     let transitions = STATE_MAP[iceState];
 
     if ("connection" in transitions) {
         this._dompc.changeIceConnectionState(transitions.connection);
     }
     if ("gathering" in transitions) {
       this._dompc.changeIceGatheringState(transitions.gathering);
+      // Handle (old, deprecated) "ongatheringchange" callback
+      this.callCB(this._dompc.ongatheringchange, transitions.gathering);
+    }
+    // Handle deprecated "onicechange" callback
+    if ("legacy" in transitions) {
+      this.callCB(this._onicechange, transitions.legacy);
     }
     if ("success" in transitions) {
       histogram.add(transitions.success);
     }
 
     if (iceState == "IceWaiting") {
       if (!this._dompc._trickleIce) {
         // If we are not trickling, then the queue is in a pending state
--- a/dom/media/tests/mochitest/pc.js
+++ b/dom/media/tests/mochitest/pc.js
@@ -1308,21 +1308,21 @@ PeerConnectionWrapper.prototype = {
 
   /**
    * Checks that we are getting the media streams we expect.
    *
    * @param {object} constraintsRemote
    *        The media constraints of the remote peer connection object
    */
   checkMediaStreams : function PCW_checkMediaStreams(constraintsRemote) {
-    is(this._pc.getLocalStreams().length, this.constraints.length,
+    is(this._pc.localStreams.length, this.constraints.length,
        this + ' has ' + this.constraints.length + ' local streams');
 
     // TODO: change this when multiple incoming streams are supported (bug 834835)
-    is(this._pc.getRemoteStreams().length, 1,
+    is(this._pc.remoteStreams.length, 1,
        this + ' has ' + 1 + ' remote streams');
   },
 
   /**
    * Check that media flow is present on all media elements involved in this
    * test by waiting for confirmation that media flow is present.
    *
    * @param {Function} onSuccess the success callback when media flow
--- a/dom/webidl/RTCPeerConnection.webidl
+++ b/dom/webidl/RTCPeerConnection.webidl
@@ -82,20 +82,20 @@ interface RTCDataChannel;
 
 [Pref="media.peerconnection.enabled",
  JSImplementation="@mozilla.org/dom/peerconnection;1",
  Constructor (optional RTCConfiguration configuration,
               optional object? constraints)]
 // moz-prefixed until sufficiently standardized.
 interface mozRTCPeerConnection : EventTarget  {
   void createOffer (RTCSessionDescriptionCallback successCallback,
-                    RTCPeerConnectionErrorCallback failureCallback,
+                    RTCPeerConnectionErrorCallback? failureCallback, // for apprtc
                     optional MediaConstraints constraints);
   void createAnswer (RTCSessionDescriptionCallback successCallback,
-                     RTCPeerConnectionErrorCallback failureCallback,
+                     RTCPeerConnectionErrorCallback? failureCallback, // for apprtc
                      optional MediaConstraints constraints);
   void setLocalDescription (mozRTCSessionDescription description,
                             optional VoidFunction successCallback,
                             optional RTCPeerConnectionErrorCallback failureCallback);
   void setRemoteDescription (mozRTCSessionDescription description,
                              optional VoidFunction successCallback,
                              optional RTCPeerConnectionErrorCallback failureCallback);
   readonly attribute mozRTCSessionDescription? localDescription;
@@ -119,16 +119,28 @@ interface mozRTCPeerConnection : EventTa
   attribute EventHandler onsignalingstatechange;
   attribute EventHandler onaddstream;
   attribute EventHandler onremovestream;
   attribute EventHandler oniceconnectionstatechange;
 
   void getStats (MediaStreamTrack? selector,
                  RTCStatsCallback successCallback,
                  RTCPeerConnectionErrorCallback failureCallback);
+};
+
+// Mozilla extensions.
+partial interface mozRTCPeerConnection {
+  // Deprecated callbacks (use causes warning)
+  attribute RTCPeerConnectionErrorCallback onicechange;
+  attribute RTCPeerConnectionErrorCallback ongatheringchange;
+
+  // Deprecated attributes (use causes warning)
+  readonly attribute object localStreams;
+  readonly attribute object remoteStreams;
+  readonly attribute DOMString readyState;
 
   // Data channel.
   RTCDataChannel createDataChannel (DOMString label,
                                     optional RTCDataChannelInit dataChannelDict);
   attribute EventHandler ondatachannel;
   attribute EventHandler onconnection;
   attribute EventHandler onclosedconnection;
 };