Bug 1263312 - Have addIceCandidate take a dictionary. r=drno,smaug
☠☠ backed out by a3fe137d4d47 ☠ ☠
authorJan-Ivar Bruaroey <jib@mozilla.com>
Tue, 08 Nov 2016 21:36:04 -0500
changeset 372776 b311b7e439e868049c07c53d82a759d962aaba2c
parent 372775 a667af08ffb5326c19321f5128d4b5227a7350aa
child 372777 33449a5d167632fb2eb731f81bcc8ac9305b33e4
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno, smaug
bugs1263312
milestone53.0a1
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
Bug 1263312 - Have addIceCandidate take a dictionary. r=drno,smaug MozReview-Commit-ID: HuWYZkGS2Wg
dom/media/PeerConnection.js
dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html
dom/webidl/RTCPeerConnection.webidl
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -972,22 +972,25 @@ RTCPeerConnection.prototype = {
     }
 
     let sections = desc.sdp.split(/(?:\r\n?|\n)m=/);
     let topSection = sections.shift();
     this._canTrickle =
       containsTrickle(topSection) || sections.every(containsTrickle);
   },
 
-
   addIceCandidate: function(c, onSuccess, onError) {
     return this._legacyCatchAndCloseGuard(onSuccess, onError, () => {
-      if (!c.candidate && !c.sdpMLineIndex) {
-        throw new this._win.DOMException("Invalid candidate passed to addIceCandidate!",
-                                         "InvalidParameterError");
+      if (!c) {
+        // TODO: Implement processing for end-of-candidates (bug 1318167)
+        return Promise.resolve();
+      }
+      if (c.sdpMid === null && c.sdpMLineIndex === null) {
+        throw new this._win.DOMException("Invalid candidate (both sdpMid and sdpMLineIndex are null).",
+                                         "TypeError");
       }
       return this._chain(() => new this._win.Promise((resolve, reject) => {
         this._onAddIceCandidateSuccess = resolve;
         this._onAddIceCandidateError = reject;
         this._impl.addIceCandidate(c.candidate, c.sdpMid || "", c.sdpMLineIndex);
       }));
     });
   },
--- a/dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html
+++ b/dom/media/tests/mochitest/test_peerConnection_addIceCandidate.html
@@ -49,55 +49,58 @@
         return test.pcRemote._pc.addIceCandidate(bogus)
         .then(
           generateErrorCallback("addIceCandidate should have failed."),
           err => {
             is(err.name, "InvalidCandidateError", "Error is InvalidCandidateError");
           }
         );
       },
-      function PC_REMOTE_ADD_CANDIDATE_MISSING_INDEX(test) {
-        // Note: it is probably not a good idea to automatically fill a missing
-        //       MLineIndex with a default value of zero, see bug 1157034
+      function PC_REMOTE_ADD_MISSING_MID_AND_MISSING_INDEX(test) {
         var broken = new RTCIceCandidate(
           {candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host"});
         return test.pcRemote._pc.addIceCandidate(broken)
         .then(
-          // FIXME this needs to be updated once bug 1157034 is fixed
-          todo(false, "Missing index in got automatically set to a valid value bz://1157034")
+          generateErrorCallback("addIceCandidate should have failed."),
+          err => {
+            is(err.name, "TypeError", "Error is TypeError");
+          }
         );
       },
       function PC_REMOTE_ADD_VALID_CANDIDATE(test) {
         var candidate = new RTCIceCandidate(
           {candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host",
            sdpMLineIndex: 0});
         return test.pcRemote._pc.addIceCandidate(candidate)
-        .then(ok(true, "Successfully added valid ICE candidate"));
+        .then(() => ok(true, "Successfully added valid ICE candidate"));
       },
       // bug 1095793
       function PC_REMOTE_ADD_MISMATCHED_MID_AND_LEVEL_CANDIDATE(test) {
         var bogus = new mozRTCIceCandidate(
           {candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host",
            sdpMLineIndex: 0,
            sdpMid: "sdparta_1"});
         return test.pcRemote._pc.addIceCandidate(bogus)
-        .then(
-          generateErrorCallback("addIceCandidate should have failed."),
-          err => {
-            is(err.name, "InvalidCandidateError", "Error is InvalidCandidateError");
-          }
-        );
+        .then(generateErrorCallback("addIceCandidate should have failed."),
+              err => is(err.name, "InvalidCandidateError", "Error is InvalidCandidateError"));
+      },
+      function PC_REMOTE_ADD_MID_AND_MISSING_INDEX(test) {
+        var candidate = new RTCIceCandidate(
+          {candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host",
+           sdpMid: "sdparta_0"});
+        return test.pcRemote._pc.addIceCandidate(candidate)
+        .then(() => ok(true, "Successfully added valid ICE candidate"));
       },
       function PC_REMOTE_ADD_MATCHING_MID_AND_LEVEL_CANDIDATE(test) {
         var candidate = new mozRTCIceCandidate(
           {candidate:"candidate:1 1 UDP 2130706431 192.168.2.1 50005 typ host",
            sdpMLineIndex: 0,
            sdpMid: "sdparta_0"});
         return test.pcRemote._pc.addIceCandidate(candidate)
-        .then(ok(true, "Successfully added valid ICE candidate with matching mid and level"));
+        .then(() => ok(true, "Successfully added valid ICE candidate with matching mid and level"));
       }
     ]);
     test.run();
   });
 </script>
 </pre>
 </body>
 </html>
--- a/dom/webidl/RTCPeerConnection.webidl
+++ b/dom/webidl/RTCPeerConnection.webidl
@@ -84,17 +84,17 @@ interface RTCPeerConnection : EventTarge
   Promise<DOMString> getIdentityAssertion();
   Promise<RTCSessionDescription> createOffer (optional RTCOfferOptions options);
   Promise<RTCSessionDescription> createAnswer (optional RTCAnswerOptions options);
   Promise<void> setLocalDescription (RTCSessionDescription description);
   Promise<void> setRemoteDescription (RTCSessionDescription description);
   readonly attribute RTCSessionDescription? localDescription;
   readonly attribute RTCSessionDescription? remoteDescription;
   readonly attribute RTCSignalingState signalingState;
-  Promise<void> addIceCandidate (RTCIceCandidate candidate);
+  Promise<void> addIceCandidate ((RTCIceCandidateInit or RTCIceCandidate)? candidate);
   readonly attribute boolean? canTrickleIceCandidates;
   readonly attribute RTCIceGatheringState iceGatheringState;
   readonly attribute RTCIceConnectionState iceConnectionState;
   [Pref="media.peerconnection.identity.enabled"]
   readonly attribute Promise<RTCIdentityAssertion> peerIdentity;
   [Pref="media.peerconnection.identity.enabled"]
   readonly attribute DOMString? idpLoginUrl;