tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RTCPeerConnection-transport-stats.https.html (1661B)


      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 src="./third_party/sdp/sdp.js"></script>
      7 <script>
      8 'use strict';
      9 
     10 // Tests for correct behavior of the transport-stats.
     11 promise_test(async t => {
     12  const pc1 = new RTCPeerConnection();
     13  t.add_cleanup(() => pc1.close());
     14  pc1.createDataChannel('wpt');
     15  await pc1.setLocalDescription();
     16  const stats = await pc1.getStats();
     17  let transportStats;
     18  stats.forEach(report => {
     19    if (report.type === 'transport') {
     20      transportStats = report;
     21    }
     22  });
     23  assert_equals(transportStats.dtlsState, 'new');
     24  assert_equals(transportStats.dtlsRole, 'unknown');
     25 }, 'DTLS statistics on transport-stats after setLocalDescription');
     26 
     27 promise_test(async t => {
     28  const pc1 = new RTCPeerConnection();
     29  t.add_cleanup(() => pc1.close());
     30  pc1.createDataChannel('wpt');
     31  await pc1.setLocalDescription();
     32  const sections = SDPUtils.splitSections(pc1.localDescription.sdp);
     33  const iceParameters = SDPUtils.getIceParameters(sections[1], sections[0]);
     34  const stats = await pc1.getStats();
     35  let transportStats;
     36  stats.forEach(report => {
     37    if (report.type === 'transport') {
     38      transportStats = report;
     39    }
     40  });
     41  assert_equals(transportStats.iceRole, 'controlling');
     42  assert_equals(transportStats.iceLocalUsernameFragment, iceParameters.usernameFragment);
     43  assert_equals(transportStats.iceState, 'new');
     44  assert_equals(transportStats.selectedCandidatePairChanges, 0);
     45 }, 'ICE statistics on transport-stats after setLocalDescription');
     46 </script>