function trackSwitchingStream() {
  let pc = new RTCPeerConnection();
  let track = null;
  let stream1 = null;
  let stream2 = null;
  pc.setRemoteDescription(createOffer([msid('stream1', 'track1')]));
  pc.ontrack = (e) => {
    track = e.track;
    stream1 = e.streams[0];
    if (stream1.getTracks()[0] != track)
      throw failTest('stream1 does not contain track.');
    // This should update the associated set of streams for the existing
    // receiver for track.
    pc.setRemoteDescription(createOffer([msid('stream2', 'track')]));
    pc.ontrack = (e) => {
      let originalTrack = track;
      track = e.track;
      stream2 = e.streams[0];
      // TODO(hbos): A new track should not be created, track should simply
      // move. Fix this and update assertion. https://crbug.com/webrtc/8377
      if (track == originalTrack)
        throw failTest('A new track was not created.');
      if (stream1.getTracks().length != 0)
        throw failTest('stream1 is not empty.')
      if (!originalTrack.muted)
        throw failTest('Original track is not muted.');
      if (track.muted)
        throw failTest('New track is muted.');
      if (stream2.getTracks()[0] != track)
        throw failTest('stream2 does not contain track.');
      returnToTest('ok');
    };
  };
}
// TODO(hbos): Make this a web platform test instead. https://crbug.com/773472
Make this a web platform test instead.
Make this a web platform test instead .
function trackSwitchingStream() {
  let pc = new RTCPeerConnection();
  let track = null;
  let stream1 = null;
  let stream2 = null;
  pc.setRemoteDescription(createOffer([msid('stream1', 'track1')]));
  pc.ontrack = (e) => {
    track = e.track;
    stream1 = e.streams[0];
    if (stream1.getTracks()[0] != track)
      throw failTest('stream1 does not contain track.');
    pc.setRemoteDescription(createOffer([msid('stream2', 'track')]));
    pc.ontrack = (e) => {
      let originalTrack = track;
      track = e.track;
      stream2 = e.streams[0];
      if (track == originalTrack)
        throw failTest('A new track was not created.');
      if (stream1.getTracks().length != 0)
        throw failTest('stream1 is not empty.')
      if (!originalTrack.muted)
        throw failTest('Original track is not muted.');
      if (track.muted)
        throw failTest('New track is muted.');
      if (stream2.getTracks()[0] != track)
        throw failTest('stream2 does not contain track.');
      returnToTest('ok');
    };
  };
}
function trackSwitchingStream ( ) { let pc = new RTCPeerConnection ( ) ; let track = null ; let stream1 = null ; let stream2 = null ; pc . setRemoteDescription ( createOffer ( [ msid ( 'stream1' , 'track1' ) ] ) ) ; pc . ontrack = ( e ) => { track = e . track ; stream1 = e . streams [ 0 ] ; if ( stream1 . getTracks ( ) [ 0 ] != track ) throw failTest ( 'stream1 does not contain track.' ) ; pc . setRemoteDescription ( createOffer ( [ msid ( 'stream2' , 'track' ) ] ) ) ; pc . ontrack = ( e ) => { let originalTrack = track ; track = e . track ; stream2 = e . streams [ 0 ] ; if ( track == originalTrack ) throw failTest ( 'A new track was not created.' ) ; if ( stream1 . getTracks ( ) . length != 0 ) throw failTest ( 'stream1 is not empty.' ) if ( ! originalTrack . muted ) throw failTest ( 'Original track is not muted.' ) ; if ( track . muted ) throw failTest ( 'New track is muted.' ) ; if ( stream2 . getTracks ( ) [ 0 ] != track ) throw failTest ( 'stream2 does not contain track.' ) ; returnToTest ( 'ok' ) ; } ; } ; }
TODO(hbos): Make this a web platform test instead.
TODO ( hbos ) : Make this a web platform test instead .
// This should update the associated set of streams for the existing // receiver for track. // TODO(hbos): A new track should not be created, track should simply // move. Fix this and update assertion. https://crbug.com/webrtc/8377