chromium/third_party/blink/web_tests/fast/peerconnection/RTCPeerConnection-sdes-constraint.html

<!DOCTYPE html>
<html>
<head>
<title>RTCPeerConnection.createOffer</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>

sdes_constraint = {'mandatory': {'DtlsSrtpKeyAgreement': false}};

promise_test(async t => {
  let pc1 = new RTCPeerConnection();
  t.add_cleanup(() => pc1.close());
  let pc2 = new RTCPeerConnection();
  t.add_cleanup(() => pc2.close());
  let stream = await navigator.mediaDevices.getUserMedia({audio: true});
  let track = stream.getAudioTracks()[0];
  pc1.addTrack(track);
  let offer = await pc1.createOffer();
  assert_true(offer.sdp.match('\na=fingerprint') !== null);
  assert_true(offer.sdp.match('\na=crypto') === null);
  await pc1.setLocalDescription(offer);
  await pc2.setRemoteDescription(offer);
  let answer = await pc2.createAnswer();
  assert_true(answer.sdp.match('\na=fingerprint') !== null);
  assert_true(answer.sdp.match('\na=crypto') === null);
  await pc2.setLocalDescription(answer);
  await pc1.setRemoteDescription(answer);
}, 'No constraints means DTLS-SRTP');

promise_test(async t => {
  let pc1 = new RTCPeerConnection(null, sdes_constraint);
  t.add_cleanup(() => pc1.close());
  let pc2 = new RTCPeerConnection(null, sdes_constraint);
  t.add_cleanup(() => pc2.close());
  pc1.oncandidate = c => pc2.addCandidate();
  pc2.oncandidate = c => pc1.addCandidate();
  let stream = await navigator.mediaDevices.getUserMedia({audio: true});
  let track = stream.getAudioTracks()[0];
  pc1.addTrack(track);
  let offer = await pc1.createOffer();
  // assert_regexp_match doesn't work
  assert_true(offer.sdp.match('\na=fingerprint') !== null);
  assert_true(offer.sdp.match('\na=crypto') === null);
}, 'DTLS constraint false has no effect');


</script>
</body>
</html>