Bug 1313246 - allow empty username and credential in RTCPeerConnection constructor. r=bwc
authorJan-Ivar Bruaroey <jib@mozilla.com>
Wed, 26 Oct 2016 20:41:07 -0400
changeset 319792 b9851671ac002a0c1b4598e292422988d8f5b7c2
parent 319791 cd858edfb90a4bfea4087a65137e1a4b71490f11
child 319793 490cc18cf93fb8da6df4e940345f77bd463bb083
push id20748
push userphilringnalda@gmail.com
push dateFri, 28 Oct 2016 03:39:55 +0000
treeherderfx-team@715360440695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1313246
milestone52.0a1
Bug 1313246 - allow empty username and credential in RTCPeerConnection constructor. r=bwc MozReview-Commit-ID: 6EJ46BXxXW5
dom/media/PeerConnection.js
dom/media/tests/mochitest/test_peerConnection_bug825703.html
media/mtransport/nricectx.cpp
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -554,21 +554,21 @@ RTCPeerConnection.prototype = {
 
     rtcConfig.iceServers.forEach(server => {
       if (!server.urls) {
         throw new this._win.DOMException(msg + " - missing urls", "InvalidAccessError");
       }
       server.urls.forEach(urlStr => {
         let url = nicerNewURI(urlStr);
         if (url.scheme in { turn:1, turns:1 }) {
-          if (!server.username) {
+          if (server.username == undefined) {
             throw new this._win.DOMException(msg + " - missing username: " + urlStr,
                                              "InvalidAccessError");
           }
-          if (!server.credential) {
+          if (server.credential == undefined) {
             throw new this._win.DOMException(msg + " - missing credential: " + urlStr,
                                              "InvalidAccessError");
           }
           if (server.credentialType != "password") {
             this.logWarning("RTCConfiguration TURN credentialType \""+
                             server.credentialType +
                             "\" is not yet implemented. Treating as password."+
                             " https://bugzil.la/1247616");
--- a/dom/media/tests/mochitest/test_peerConnection_bug825703.html
+++ b/dom/media/tests/mochitest/test_peerConnection_bug825703.html
@@ -61,16 +61,18 @@ runNetworkTest(() => {
   makePC({ iceServers: [{ urls:"" }] }, "SyntaxError");
 
   makePC({ iceServers: [
     { urls:"stun:127.0.0.1" },
     { urls:"stun:localhost", foo:"" },
     { urls: ["stun:127.0.0.1", "stun:localhost"] },
     { urls:"stuns:localhost", foo:"" },
     { urls:"turn:[::1]:3478", username:"p", credential:"p" },
+    { urls:"turn:[::1]:3478", username:"", credential:"" },
+    { urls:"turns:[::1]:3478", username:"", credential:"" },
     { urls:"turn:localhost:3478?transport=udp", username:"p", credential:"p" },
     { urls: ["turn:[::1]:3478", "turn:localhost"], username:"p", credential:"p" },
     { urls:"turns:localhost:3478?transport=udp", username:"p", credential:"p" },
     { url:"stun:localhost", foo:"" },
     { url:"turn:localhost", username:"p", credential:"p" }
   ]});
 
   makePC({ iceServers: [{ urls: ["stun:127.0.0.1", ""] }] }, "SyntaxError");
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -238,21 +238,16 @@ nsresult NrIceStunServer::ToNicerStunStr
 
 nsresult NrIceTurnServer::ToNicerTurnStruct(nr_ice_turn_server *server) const {
   memset(server, 0, sizeof(nr_ice_turn_server));
 
   nsresult rv = ToNicerStunStruct(&server->turn_server);
   if (NS_FAILED(rv))
     return rv;
 
-  if (username_.empty())
-    return NS_ERROR_INVALID_ARG;
-  if (password_.empty())
-    return NS_ERROR_INVALID_ARG;
-
   if (!(server->username=r_strdup(username_.c_str())))
     return NS_ERROR_OUT_OF_MEMORY;
 
   // TODO(ekr@rtfm.com): handle non-ASCII passwords somehow?
   // STUN requires they be SASLpreped, but we don't know if
   // they are at this point.
 
   // C++03 23.2.4, Paragraph 1 stipulates that the elements