Skip to content

Commit

Permalink
Merge pull request #13887 from alvestrand/jsep-basic-sdp
Browse files Browse the repository at this point in the history
Basic test for generated SDP
  • Loading branch information
alvestrand authored Nov 4, 2018
2 parents 9864ae7 + 79745f4 commit da8939d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions webrtc/protocol/jsep-initial-offer.https.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<meta charset=utf-8>
<title>RTCPeerConnection.prototype.createOffer</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../RTCPeerConnection-helper.js"></script>
<script>
'use strict';

// Tests for the construction of initial offers according to
// draft-ietf-rtcweb-jsep-24 section 5.2.1
promise_test(async t => {
const pc = new RTCPeerConnection();
const offer = await pc.createOffer({offerToReceiveVideo: true});
let offer_lines = offer.sdp.split('\r\n');
// The first 3 lines are dictated by JSEP.
assert_equals(offer_lines[0], "v=0");
assert_equals(offer_lines[1].slice(0, 2), "o=");
// JSEP says that the address part SHOULD be a meaningless address
// "such as" IN IP4 127.0.0.1. We do strict matching here in order
// to detect if anyone ever uses something different.
assert_regexp_match(offer_lines[1], /^o=- \d+ \d+ IN IP4 127.0.0.1$/);
const fields = RegExp(/^o=- (\d+) (\d+)/).exec(offer_lines[1]);
// Per RFC 3264, the sess-id should be representable in an uint64
// Note: JSEP -24 has this wrong - see bug:
// https://github.com/rtcweb-wg/jsep/issues/855
assert_less_than(Number(fields[1]), 2**64);
// Per RFC 3264, the version should be less than 2^62 to avoid overflow
assert_less_than(Number(fields[2]), 2**62);
// Note: using - in s=- is a SHOULD in JSEP, not a MUST.
assert_equals(offer_lines[2], "s=-");
// After this, the order is not dictated by JSEP.
// TODO: Check lines subsequent to the s= line.
}, 'Offer conforms to basic SDP requirements');
</script>

0 comments on commit da8939d

Please sign in to comment.