tor-browser

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

test_peerConnection_removeThenAddVideoTrackNoBundle.html (3365B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript" src="pc.js"></script>
      5  <script type="application/javascript" src="/tests/dom/canvas/test/captureStream_common.js"></script>
      6 </head>
      7 <body>
      8 <pre id="test">
      9 <script type="application/javascript">
     10  createHTML({
     11    bug: "1017888",
     12    title: "Renegotiation: remove then add video track, no bundle"
     13  });
     14 
     15  runNetworkTest(async function (options) {
     16    // Use fake video here since the native fake device on linux doesn't
     17    // change color as needed by checkVideoPlaying() below.
     18    await pushPrefs(
     19      ['media.video_loopback_dev', ''],
     20      ['media.navigator.streams.fake', true]);
     21    // [TODO] re-enable HW decoder after bug 1526207 is fixed.
     22    if (navigator.userAgent.includes("Android")) {
     23      await pushPrefs(["media.navigator.mediadatadecoder_vpx_enabled", false],
     24                      ["media.webrtc.hw.h264.enabled", false]);
     25    }
     26 
     27    options = options || { };
     28    options.bundle = false;
     29    const test = new PeerConnectionTest(options);
     30    const helper = new VideoStreamHelper();
     31    var originalTrack;
     32    addRenegotiation(test.chain,
     33      [
     34        function PC_REMOTE_FIND_RECEIVER(test) {
     35          is(test.pcRemote._pc.getReceivers().length, 1,
     36             "pcRemote should have one receiver");
     37          originalTrack = test.pcRemote._pc.getReceivers()[0].track;
     38        },
     39        function PC_LOCAL_REMOVE_VIDEO_TRACK(test) {
     40          // The new track's pipeline will start with a packet count of
     41          // 0, but the remote side will keep its old pipeline and packet
     42          // count.
     43          test.pcLocal.disableRtpCountChecking = true;
     44          return test.pcLocal.removeSender(0);
     45        },
     46        function PC_LOCAL_ADD_VIDEO_TRACK(test) {
     47          // Use fake:true here since the native fake device on linux doesn't
     48          // change color as needed by checkVideoPlaying() below.
     49          return test.pcLocal.getAllUserMediaAndAddStreams([{video: true}]);
     50        },
     51        function PC_LOCAL_EXPECT_ICE_CHECKING(test) {
     52          test.pcLocal.expectIceChecking();
     53        },
     54        function PC_REMOTE_EXPECT_ICE_CHECKING(test) {
     55          test.pcRemote.expectIceChecking();
     56        },
     57      ],
     58      [
     59        function PC_REMOTE_CHECK_ADDED_TRACK(test) {
     60          is(test.pcRemote._pc.getTransceivers().length, 2,
     61              "pcRemote should have two transceivers");
     62          const track = test.pcRemote._pc.getTransceivers()[1].receiver.track;
     63 
     64          const vAdded = test.pcRemote.remoteMediaElements.find(
     65              elem => elem.id.includes(track.id));
     66          return helper.checkVideoPlaying(vAdded);
     67        },
     68        function PC_REMOTE_CHECK_REMOVED_TRACK(test) {
     69          is(test.pcRemote._pc.getTransceivers().length, 2,
     70              "pcRemote should have two transceivers");
     71          const track = test.pcRemote._pc.getTransceivers()[0].receiver.track;
     72 
     73          const vAdded = test.pcRemote.remoteMediaElements.find(
     74              elem => elem.id.includes(track.id));
     75          return helper.checkVideoPaused(vAdded, 10, 10, 16, 5000);
     76        },
     77      ]
     78    );
     79 
     80    test.chain.insertAfterEach('PC_LOCAL_CREATE_OFFER',
     81                               PC_LOCAL_REMOVE_BUNDLE_FROM_OFFER);
     82 
     83    test.setMediaConstraints([{video: true}], [{video: true}]);
     84    await test.run();
     85  });
     86 </script>
     87 </pre>
     88 </body>
     89 </html>