DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (05f4ac2d6dd6)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
<!DOCTYPE HTML>
<html>
<head>
  <script type="application/javascript" src="pc.js"></script>
</head>
<body>
<pre id="test">
<script type="application/javascript">
"use strict";

createHTML({
  title: "MediaStream's 'addtrack' and 'removetrack' events with gUM",
  bug: "1208328"
});

runNetworkTest(function (options) {
  let test = new PeerConnectionTest(options);
  let eventsPromise;
  addRenegotiation(test.chain,
    [
      function PC_LOCAL_SWAP_VIDEO_TRACKS(test) {
        return getUserMedia({video: true}).then(stream => {
          var videoTransceiver = test.pcLocal._pc.getTransceivers()[1];
          is(videoTransceiver.currentDirection, "sendonly",
             "Video transceiver's current direction is sendonly");
          is(videoTransceiver.direction, "sendrecv",
             "Video transceiver's desired direction is sendrecv");

          const localStream = test.pcLocal._pc.getLocalStreams()[0];
          ok(localStream, "Should have local stream");

          const remoteStream = test.pcRemote._pc.getRemoteStreams()[0];
          ok(remoteStream, "Should have remote stream");

          const newTrack = stream.getTracks()[0];

          const videoSenderIndex =
            test.pcLocal._pc.getSenders().findIndex(s => s.track.kind == "video");
          isnot(videoSenderIndex, -1, "Should have video sender");

          test.pcLocal.removeSender(videoSenderIndex);
          is(videoTransceiver.direction, "recvonly",
             "Video transceiver should be recvonly after removeTrack");
          test.pcLocal.attachLocalTrack(stream.getTracks()[0], localStream);
          is(videoTransceiver.direction, "recvonly",
             "Video transceiver should be recvonly after addTrack");

          eventsPromise = haveEvent(remoteStream, "addtrack",
              wait(50000, new Error("No addtrack event for " + newTrack.id)))
            .then(trackEvent => {
              ok(trackEvent instanceof MediaStreamTrackEvent,
                 "Expected event to be instance of MediaStreamTrackEvent");
              is(trackEvent.type, "addtrack",
                 "Expected addtrack event type");
              is(trackEvent.track.readyState, "live",
                 "added track should be live");
            })
            .then(() => haveNoEvent(remoteStream, "addtrack"));
        });
      },
    ],
    [
      function PC_REMOTE_CHECK_EVENTS(test) {
        return eventsPromise;
      },
    ]
  );

  test.setMediaConstraints([{audio: true, video: true}], []);
  test.run();
});
</script>
</pre>
</body>
</html>