Bug 1535410: Check for null mid/level in addIceCandidate. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 19 Mar 2019 16:49:05 +0000
changeset 465099 05ae948300ea8fd0b963bbd35828ed52bfee2a6e
parent 465098 5e2514122d46dce21c9658c568faef0bb5f0531f
child 465100 05f0176414e72fea9214d49b5ff443bba1bb0d8b
push id35732
push useropoprus@mozilla.com
push dateWed, 20 Mar 2019 10:52:37 +0000
treeherdermozilla-central@708979f9c3f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1535410
milestone68.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 1535410: Check for null mid/level in addIceCandidate. r=jib Differential Revision: https://phabricator.services.mozilla.com/D23727
dom/media/PeerConnection.jsm
testing/web-platform/meta/webrtc/RTCPeerConnection-addIceCandidate.html.ini
--- a/dom/media/PeerConnection.jsm
+++ b/dom/media/PeerConnection.jsm
@@ -1106,22 +1106,24 @@ class RTCPeerConnection {
 
     let sections = desc.sdp.split(/(?:\r\n?|\n)m=/);
     let topSection = sections.shift();
     this._canTrickle =
       containsTrickle(topSection) || sections.every(containsTrickle);
   }
 
   addIceCandidate(cand, onSucc, onErr) {
-    if (cand === null) {
+    if (cand.candidate != "" &&
+        cand.sdpMid == null &&
+        cand.sdpMLineIndex == null) {
       throw new this._win.DOMException(
-        "Empty candidate can not be added.",
+        "Cannot add a candidate without specifying either sdpMid or sdpMLineIndex",
         "TypeError");
     }
-    return this._auto(onSucc, onErr, () => cand && this._addIceCandidate(cand));
+    return this._auto(onSucc, onErr, () => this._addIceCandidate(cand));
   }
 
   async _addIceCandidate({ candidate, sdpMid, sdpMLineIndex, usernameFragment }) {
     this._checkClosed();
     return this._chain(() => {
       return new Promise((resolve, reject) => {
         this._onAddIceCandidateSuccess = resolve;
         this._onAddIceCandidateError = reject;
--- a/testing/web-platform/meta/webrtc/RTCPeerConnection-addIceCandidate.html.ini
+++ b/testing/web-platform/meta/webrtc/RTCPeerConnection-addIceCandidate.html.ini
@@ -1,21 +1,9 @@
 [RTCPeerConnection-addIceCandidate.html]
-  [Add candidate with both sdpMid and sdpMLineIndex manually set to null should reject with TypeError]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1535410
-
-  [Add candidate with only valid candidate string should reject with TypeError]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1535410
-
-  [Add candidate with invalid candidate string and both sdpMid and sdpMLineIndex null should reject with TypeError]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1535410
-
   [Add candidate with invalid usernameFragment should reject with OperationError]
     expected: FAIL
     bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1535442
 
   [Add candidate with sdpMid belonging to different usernameFragment should reject with OperationError]
     expected: FAIL
     bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1535442