dtls-setup.https.html (4598B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>RTCPeerConnection a=setup SDP parameter test</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script> 7 'use strict'; 8 9 // Tests for correct behavior of DTLS a=setup parameter. 10 11 // SDP copied from JSEP Example 7.1 12 // It contains two media streams with different ufrags, and bundle 13 // turned on. 14 const kSdp = `v=0 15 o=- 4962303333179871722 1 IN IP4 0.0.0.0 16 s=- 17 t=0 0 18 a=ice-options:trickle 19 a=group:BUNDLE a1 v1 20 a=group:LS a1 v1 21 m=audio 10100 UDP/TLS/RTP/SAVPF 96 0 8 97 98 22 c=IN IP4 203.0.113.100 23 a=mid:a1 24 a=sendrecv 25 a=rtpmap:96 opus/48000/2 26 a=rtpmap:0 PCMU/8000 27 a=rtpmap:8 PCMA/8000 28 a=rtpmap:97 telephone-event/8000 29 a=rtpmap:98 telephone-event/48000 30 a=maxptime:120 31 a=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid 32 a=extmap:2 urn:ietf:params:rtp-hdrext:ssrc-audio-level 33 a=msid:47017fee-b6c1-4162-929c-a25110252400 f83006c5-a0ff-4e0a-9ed9-d3e6747be7d9 34 a=ice-ufrag:ETEn 35 a=ice-pwd:OtSK0WpNtpUjkY4+86js7ZQl 36 a=fingerprint:sha-256 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04:BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 37 a=setup:actpass 38 a=dtls-id:1 39 a=rtcp:10101 IN IP4 203.0.113.100 40 a=rtcp-mux 41 a=rtcp-rsize 42 m=video 10102 UDP/TLS/RTP/SAVPF 100 101 43 c=IN IP4 203.0.113.100 44 a=mid:v1 45 a=sendrecv 46 a=rtpmap:100 VP8/90000 47 a=rtpmap:101 rtx/90000 48 a=fmtp:101 apt=100 49 a=extmap:1 urn:ietf:params:rtp-hdrext:sdes:mid 50 a=rtcp-fb:100 ccm fir 51 a=rtcp-fb:100 nack 52 a=rtcp-fb:100 nack pli 53 a=msid:47017fee-b6c1-4162-929c-a25110252400 f30bdb4a-5db8-49b5-bcdc-e0c9a23172e0 54 a=ice-ufrag:BGKk 55 a=ice-pwd:mqyWsAjvtKwTGnvhPztQ9mIf 56 a=fingerprint:sha-256 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04:BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2 57 a=setup:actpass 58 a=dtls-id:1 59 a=rtcp:10103 IN IP4 203.0.113.100 60 a=rtcp-mux 61 a=rtcp-rsize 62 `; 63 64 for (let setup of ['actpass', 'active', 'passive']) { 65 promise_test(async t => { 66 const sdp = kSdp.replace(/a=setup:actpass/g, 67 'a=setup:' + setup); 68 const pc1 = new RTCPeerConnection(); 69 t.add_cleanup(() => pc1.close()); 70 await pc1.setRemoteDescription({type: 'offer', sdp: sdp}); 71 const answer = await pc1.createAnswer(); 72 const resultingSetup = answer.sdp.match(/a=setup:\S+/); 73 if (setup === 'active') { 74 assert_equals(resultingSetup[0], 'a=setup:passive'); 75 } else if (setup === 'passive') { 76 assert_equals(resultingSetup[0], 'a=setup:active'); 77 } else if (setup === 'actpass') { 78 // For actpass, either active or passive are legal, although 79 // active is RECOMMENDED by RFC 5763 / 8842. 80 assert_in_array(resultingSetup[0], ['a=setup:active', 'a=setup:passive']); 81 } 82 await pc1.setLocalDescription(answer); 83 }, 'PC should accept initial offer with setup=' + setup); 84 } 85 86 for (let setup of ['actpass', 'active', 'passive']) { 87 const roleMap = { 88 actpass: 'client', 89 active: 'server', 90 passive: 'client', 91 }; 92 promise_test(async t => { 93 const sdp = kSdp.replace(/a=setup:actpass/g, 94 'a=setup:' + setup); 95 const pc1 = new RTCPeerConnection(); 96 t.add_cleanup(() => pc1.close()); 97 await pc1.setRemoteDescription({type: 'offer', sdp: sdp}); 98 const answer = await pc1.createAnswer(); 99 const resultingSetup = answer.sdp.match(/a=setup:\S+/); 100 if (setup === 'active') { 101 assert_equals(resultingSetup[0], 'a=setup:passive'); 102 } else if (setup === 'passive') { 103 assert_equals(resultingSetup[0], 'a=setup:active'); 104 } else if (setup === 'actpass') { 105 // For actpass, either active or passive are legal, although 106 // active is RECOMMENDED by RFC 5763 / 8842. 107 assert_in_array(resultingSetup[0], ['a=setup:active', 'a=setup:passive']); 108 } 109 await pc1.setLocalDescription(answer); 110 const stats = await pc1.getStats(); 111 let transportStats; 112 stats.forEach(report => { 113 if (report.type === 'transport' && report.dtlsRole) { 114 transportStats = report; 115 } 116 }); 117 assert_equals(transportStats.dtlsRole, roleMap[setup]); 118 }, 'PC with setup=' + setup + ' should have a dtlsRole of ' + roleMap[setup]); 119 } 120 121 promise_test(async t => { 122 const pc1 = new RTCPeerConnection(); 123 t.add_cleanup(() => pc1.close()); 124 pc1.createDataChannel("wpt"); 125 await pc1.setLocalDescription(); 126 const stats = await pc1.getStats(); 127 let transportStats; 128 stats.forEach(report => { 129 if (report.type === 'transport' && report.dtlsRole) { 130 transportStats = report; 131 } 132 }); 133 assert_equals(transportStats.dtlsRole, 'unknown'); 134 }, 'dtlsRole is `unknown` before negotiation of the DTLS handshake'); 135 </script>