jsep-initial-offer.https.html (1963B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>RTCPeerConnection.prototype.createOffer</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="../RTCPeerConnection-helper.js"></script> 7 <script> 8 'use strict'; 9 10 // Tests for the construction of initial offers according to 11 // draft-ietf-rtcweb-jsep-24 section 5.2.1 12 promise_test(async t => { 13 const pc = new RTCPeerConnection(); 14 const offer = await generateVideoReceiveOnlyOffer(pc); 15 let offer_lines = offer.sdp.split('\r\n'); 16 // The first 3 lines are dictated by JSEP. 17 assert_equals(offer_lines[0], "v=0"); 18 assert_equals(offer_lines[1].slice(0, 2), "o="); 19 20 assert_regexp_match(offer_lines[1], /^o=\S+ \d+ \d+ IN IP4 \S+$/); 21 const fields = RegExp(/^o=\S+ (\d+) (\d+) IN IP4 (\S+)/).exec(offer_lines[1]); 22 // Per RFC 3264, the sess-id should be representable in an uint64 23 // Note: JSEP -24 has this wrong - see bug: 24 // https://github.com/rtcweb-wg/jsep/issues/855 25 assert_less_than(Number(fields[1]), 2**64); 26 // Per RFC 3264, the version should be less than 2^62 to avoid overflow 27 assert_less_than(Number(fields[2]), 2**62); 28 // JSEP says that the address part SHOULD be a meaningless address 29 // "such as" IN IP4 0.0.0.0. This is to prevent unintentional disclosure 30 // of IP addresses, so this is important enough to verify. Right now we 31 // allow 127.0.0.1 and 0.0.0.0, but there are other things we could allow. 32 // Maybe 0.0.0.0/8, 127.0.0.0/8, 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24? 33 // (See RFC 3330, RFC 5737) 34 assert_true(fields[3] == "0.0.0.0" || fields[3] == "127.0.0.1", 35 fields[3] + " must be a meaningless IPV4 address") 36 37 assert_regexp_match(offer_lines[2], /^s=\S+$/); 38 // After this, the order is not dictated by JSEP. 39 // TODO: Check lines subsequent to the s= line. 40 }, 'Offer conforms to basic SDP requirements'); 41 </script>