tor-browser

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

test_peerConnection_trackless_sender_stats.html (2058B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5  <script type="application/javascript" src="stats.js"></script>
      6 </head>
      7 <body>
      8 <pre id="test">
      9 <script type="application/javascript">
     10  createHTML({
     11    bug: "1452673",
     12    title: "Trackless RTCRtpSender.getStats()",
     13    visible: true
     14  });
     15 
     16  // Calling getstats() on a trackless RTCRtpSender should yield an empty
     17  // stats report.  When track stats are added in the future, the stats
     18  // for the removed tracks should continue to appear.
     19 
     20  runNetworkTest(function (options) {
     21    const test = new PeerConnectionTest(options);
     22    test.chain.removeAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW");
     23    test.chain.append(
     24      async function PC_LOCAL_AND_REMOTE_TRACKLESS_SENDER_STATS(test) {
     25        await Promise.all([
     26          waitForSyncedRtcp(test.pcLocal._pc),
     27          waitForSyncedRtcp(test.pcRemote._pc),
     28        ]);
     29        let senders = test.pcLocal.getSenders();
     30        let receivers = test.pcRemote.getReceivers();
     31        is(senders.length, 2, "Have exactly two senders.");
     32        is(receivers.length, 2, "Have exactly two receivers.");
     33        for(let kind of ["audio", "video"]) {
     34          is(senders.filter(s => s.track.kind == kind).length, 1,
     35              "Exactly 1 sender of kind " + kind);
     36          is(receivers.filter(r => r.track.kind == kind).length, 1,
     37              "Exactly 1 receiver of kind " + kind);
     38        }
     39        // Remove tracks from senders
     40        for (const sender of senders) {
     41          await sender.replaceTrack(null);
     42          is(sender.track, null, "Sender track removed");
     43          let stats = await sender.getStats();
     44          ok(stats instanceof window.RTCStatsReport, "Stats is instance of RTCStatsReport");
     45          // Number of stats in the report. This should not be 0.
     46          ok(stats.size > 0, "Replace track with null should still return stats");
     47        }
     48      }
     49    );
     50    test.setMediaConstraints([{audio: true}, {video: true}], []);
     51    return test.run();
     52  });
     53 </script>
     54 </pre>
     55 </body>
     56 </html>