static/tests/frontend/specs/race_conditions.js
// "deactivating" webrtc, and "activating" webrtc in quick succession
"deactivating" webrtc, and "activating" webrtc in quick succession
" deactivating " webrtc and " activating " webrtc in quick succession
function testClickDeactivateActivate(done) {
    const chrome$ = helper.padChrome$;
    function loop(i) {
      originalAudioTrack = audioTrack;
      expect(originalAudioTrack).to.equal(audioTrack);
      expect(chrome$('.audio-btn').hasClass('muted')).to.equal(!audioTrack.enabled);
      originalVideoTrack = videoTrack;
      expect(originalVideoTrack).to.equal(videoTrack);
      expect(chrome$('.video-btn').hasClass('off')).to.equal(!videoTrack.enabled);
      chrome$('.audio-btn').click();
      chrome$('.video-btn').click();
      chrome$.window.ep_webrtc.deactivate();
      chrome$.window.ep_webrtc.activate().then(() => {
        expect(originalAudioTrack).to.not.equal(audioTrack);
        expect(originalAudioTrack.readyState).to.equal('ended');
        expect(audioTrack.readyState).to.equal('live');
        expect(originalVideoTrack).to.not.equal(videoTrack);
        expect(originalVideoTrack.readyState).to.equal('ended');
        expect(videoTrack.readyState).to.equal('live');
        expect(chrome$('.audio-btn').hasClass('muted')).to.equal(!audioTrack.enabled);
        expect(chrome$('.video-btn').hasClass('off')).to.equal(!videoTrack.enabled);
        if (i > 0) {
          return loop(i - 1);
        } else {
          done();
        }
      });
    }
    loop(10);
  }
function testClickDeactivateActivate ( done ) { const chrome$ = helper . padChrome$ ; function loop ( i ) { originalAudioTrack = audioTrack ; expect ( originalAudioTrack ) . to . equal ( audioTrack ) ; expect ( chrome$ ( '.audio-btn' ) . hasClass ( 'muted' ) ) . to . equal ( ! audioTrack . enabled ) ; originalVideoTrack = videoTrack ; expect ( originalVideoTrack ) . to . equal ( videoTrack ) ; expect ( chrome$ ( '.video-btn' ) . hasClass ( 'off' ) ) . to . equal ( ! videoTrack . enabled ) ; chrome$ ( '.audio-btn' ) . click ( ) ; chrome$ ( '.video-btn' ) . click ( ) ; chrome$ . window . ep_webrtc . deactivate ( ) ; chrome$ . window . ep_webrtc . activate ( ) . then ( ( ) => { expect ( originalAudioTrack ) . to . not . equal ( audioTrack ) ; expect ( originalAudioTrack . readyState ) . to . equal ( 'ended' ) ; expect ( audioTrack . readyState ) . to . equal ( 'live' ) ; expect ( originalVideoTrack ) . to . not . equal ( videoTrack ) ; expect ( originalVideoTrack . readyState ) . to . equal ( 'ended' ) ; expect ( videoTrack . readyState ) . to . equal ( 'live' ) ; expect ( chrome$ ( '.audio-btn' ) . hasClass ( 'muted' ) ) . to . equal ( ! audioTrack . enabled ) ; expect ( chrome$ ( '.video-btn' ) . hasClass ( 'off' ) ) . to . equal ( ! videoTrack . enabled ) ; if ( i > 0 ) { return loop ( i - 1 ) ; } else { done ( ) ; } } ) ; } loop ( 10 ) ; }
"deactivating" webrtc, and "activating" webrtc in quick succession
" deactivating " webrtc and " activating " webrtc in quick succession
// getUserMedia should give us new audio and video Tracks and disable the old one // The mute state should be consistent with icon, wherever they land