tor-browser

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

test_peerConnection_addSecondAudioStreamNoBundle.html (2104B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5 </head>
      6 <body>
      7 <pre id="test">
      8 <script type="application/javascript">
      9  createHTML({
     10    bug: "1017888",
     11    title: "Renegotiation: add second audio stream, no bundle"
     12  });
     13 
     14  runNetworkTest(function (options = {}) {
     15    options.bundle = false;
     16    const test = new PeerConnectionTest(options);
     17    addRenegotiation(test.chain,
     18      [
     19        function PC_LOCAL_ADD_SECOND_STREAM(test) {
     20          test.setMediaConstraints([{audio: true}, {audio: true}],
     21                                   [{audio: true}]);
     22          // Since this is a NoBundle variant, adding a track will cause us to
     23          // go back to checking.
     24          test.pcLocal.expectIceChecking();
     25          return test.pcLocal.getAllUserMediaAndAddStreams([{audio: true}]);
     26        },
     27        function PC_REMOTE_EXPECT_ICE_CHECKING(test) {
     28          test.pcRemote.expectIceChecking();
     29        },
     30      ],
     31      [
     32        function PC_REMOTE_CHECK_ADDED_TRACK(test) {
     33          // We test both tracks to avoid an ordering problem
     34          is(test.pcRemote._pc.getReceivers().length, 2,
     35             "pcRemote should have two receivers");
     36          const audioContext = new AudioContext();
     37          // Start a tone so that the gUM call will record something even
     38          // with --use-test-media-devices.
     39          const tone = new LoopbackTone(audioContext, TEST_AUDIO_FREQ);
     40          tone.start();
     41          return Promise.all(test.pcRemote._pc.getReceivers().map(r => {
     42            const analyser = new AudioStreamAnalyser(
     43                new AudioContext(), new MediaStream([r.track]));
     44            const freq = analyser.binIndexForFrequency(TEST_AUDIO_FREQ);
     45            return analyser.waitForAnalysisSuccess(arr => arr[freq] > 200);
     46          }))
     47            .finally(() => tone.stop());
     48        },
     49      ]
     50    );
     51 
     52    // TODO(bug 1093835): figure out how to verify if media flows through the new stream
     53    test.setMediaConstraints([{audio: true}], [{audio: true}]);
     54    return test.run();
     55  });
     56 </script>
     57 </pre>
     58 </body>
     59 </html>