Bug 1098314 - Ignore and warn on turns: and stuns: urls until we support TURN/STUN TLS. r=bwc, a=sledru
authorJan-Ivar Bruaroey <jib@mozilla.com>
Mon, 17 Nov 2014 22:18:49 -0500
changeset 242833 3b4908a629e8
parent 242832 36535f9806e6
child 242834 3956d52ad3f0
push id4319
push userryanvm@gmail.com
push date2015-01-14 14:36 +0000
treeherdermozilla-beta@f6d5f2303fea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc, sledru
bugs1098314
milestone36.0
Bug 1098314 - Ignore and warn on turns: and stuns: urls until we support TURN/STUN TLS. r=bwc, a=sledru
dom/media/PeerConnection.js
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -334,16 +334,18 @@ RTCPeerConnection.prototype = {
   init: function(win) { this._win = win; },
 
   __init: function(rtcConfig) {
     if (!rtcConfig.iceServers ||
         !Services.prefs.getBoolPref("media.peerconnection.use_document_iceservers")) {
       rtcConfig.iceServers =
         JSON.parse(Services.prefs.getCharPref("media.peerconnection.default_iceservers"));
     }
+    this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
+      .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
     this._mustValidateRTCConfiguration(rtcConfig,
         "RTCPeerConnection constructor passed invalid RTCConfiguration");
     if (_globalPCList._networkdown || !this._win.navigator.onLine) {
       throw new this._win.DOMError("",
           "Can't create RTCPeerConnections when the network is down");
     }
 
     this.makeGetterSetterEH("onaddstream");
@@ -360,18 +362,16 @@ RTCPeerConnection.prototype = {
     this.makeGetterSetterEH("onidpvalidationerror");
 
     this._pc = new this._win.PeerConnectionImpl();
 
     this.__DOM_IMPL__._innerObject = this;
     this._observer = new this._win.PeerConnectionObserver(this.__DOM_IMPL__);
 
     // Add a reference to the PeerConnection to global list (before init).
-    this._winID = this._win.QueryInterface(Ci.nsIInterfaceRequestor)
-      .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
     _globalPCList.addPC(this);
 
     this._queueOrRun({
       func: this._initialize,
       args: [rtcConfig],
       wait: false
     });
   },
@@ -456,16 +456,17 @@ RTCPeerConnection.prototype = {
    *                     username:"jib", credential:"mypass"} ] }
    *
    * WebIDL normalizes structure for us, so we test well-formed stun/turn urls,
    * but not validity of servers themselves, before passing along to C++.
    * ErrorMsg is passed in to detail which array-entry failed, if any.
    */
   _mustValidateRTCConfiguration: function(rtcConfig, errorMsg) {
     var errorCtor = this._win.DOMError;
+    var warningFunc = this.logWarning.bind(this);
     function nicerNewURI(uriStr, errorMsg) {
       let ios = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
       try {
         return ios.newURI(uriStr, null, null);
       } catch (e if (e.result == Cr.NS_ERROR_MALFORMED_URI)) {
         throw new errorCtor("", errorMsg + " - malformed URI: " + uriStr);
       }
     }
@@ -481,16 +482,19 @@ RTCPeerConnection.prototype = {
         if (!server.credential) {
           throw new errorCtor("", errorMsg + " - missing credential: " +
                               server.url);
         }
       }
       else if (!(url.scheme in { stun:1, stuns:1 })) {
         throw new errorCtor("", errorMsg + " - improper scheme: " + url.scheme);
       }
+      if (url.scheme in { stuns:1, turns:1 }) {
+        warningFunc(url.scheme.toUpperCase() + " is not yet supported.", null, 0);
+      }
     }
     if (rtcConfig.iceServers) {
       let len = rtcConfig.iceServers.length;
       for (let i=0; i < len; i++) {
         mustValidateServer (rtcConfig.iceServers[i], errorMsg);
       }
     }
   },
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -408,16 +408,19 @@ PeerConnectionImpl::ConvertRTCConfigurat
     bool isStun = false, isStuns = false, isTurn = false, isTurns = false;
     url->SchemeIs("stun", &isStun);
     url->SchemeIs("stuns", &isStuns);
     url->SchemeIs("turn", &isTurn);
     url->SchemeIs("turns", &isTurns);
     if (!(isStun || isStuns || isTurn || isTurns)) {
       return NS_ERROR_FAILURE;
     }
+    if (isTurns || isStuns) {
+      continue; // TODO: Support TURNS and STUNS (Bug 1056934)
+    }
     nsAutoCString spec;
     rv = url->GetSpec(spec);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // TODO(jib@mozilla.com): Revisit once nsURI supports STUN/TURN (Bug 833509)
     int32_t port;
     nsAutoCString host;
     nsAutoCString transport;