Commit 39c5a6c3 authored by Byron Campen [:bwc]'s avatar Byron Campen [:bwc]
Browse files

Bug 1531110: Handle setLocalDescription (either offer or answer) with empty sdp string. r=mjf,jib

Depends on D24216

Differential Revision: https://phabricator.services.mozilla.com/D24245

--HG--
extra : moz-landing-system : lando
parent 645ffc22
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -926,12 +926,6 @@ class RTCPeerConnection {
                                       "NotSupportedError");
    }

    if (!sdp && action != Ci.IPeerConnection.kActionRollback) {
      throw new this._win.DOMException(
          "Empty or null SDP provided to setLocalDescription",
          "InvalidParameterError");
    }

    // The fippo butter finger filter AKA non-ASCII chars
    // Note: SDP allows non-ASCII character in the subject (who cares?)
    // eslint-disable-next-line no-control-regex
+34 −11
Original line number Diff line number Diff line
@@ -623,14 +623,37 @@ nsresult JsepSessionImpl::DetermineAnswererSetupRole(
}

nsresult JsepSessionImpl::SetLocalDescription(JsepSdpType type,
                                              const std::string& sdp) {
                                              const std::string& constSdp) {
  mLastError.clear();
  std::string sdp = constSdp;

  MOZ_MTLOG(ML_DEBUG, "[" << mName << "]: SetLocalDescription type=" << type
                          << "\nSDP=\n"
                          << sdp);

  if (type == kJsepSdpRollback) {
  switch (type) {
    case kJsepSdpOffer:
      if (!mGeneratedOffer) {
        JSEP_SET_ERROR(
            "Cannot set local offer when createOffer has not been called.");
        return NS_ERROR_UNEXPECTED;
      }
      if (sdp.empty()) {
        sdp = mGeneratedOffer->ToString();
      }
      break;
    case kJsepSdpAnswer:
    case kJsepSdpPranswer:
      if (!mGeneratedAnswer) {
        JSEP_SET_ERROR(
            "Cannot set local answer when createAnswer has not been called.");
        return NS_ERROR_UNEXPECTED;
      }
      if (sdp.empty()) {
        sdp = mGeneratedAnswer->ToString();
      }
      break;
    case kJsepSdpRollback:
      if (mState != kJsepStateHaveLocalOffer) {
        JSEP_SET_ERROR("Cannot rollback local description in "
                       << GetStateStr(mState));
+0 −4
Original line number Diff line number Diff line
[RTCPeerConnection-setLocalDescription-answer.html]
  [setLocalDescription() with type answer and null sdp should use lastAnswer generated from createAnswer]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1531110

  [setLocalDescription() with answer not created by own createAnswer() should reject with InvalidModificationError]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1531118, https://bugzilla.mozilla.org/show_bug.cgi?id=1095226
+0 −4
Original line number Diff line number Diff line
[RTCPeerConnection-setLocalDescription-offer.html]
  [setLocalDescription with type offer and null sdp should use lastOffer generated from createOffer]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1531110

  [setLocalDescription() with offer not created by own createOffer() should reject with InvalidModificationError]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1531134