forked from mirrors/gecko-dev
		
	MozReview-Commit-ID: CQzdR66hsXZ --HG-- rename : testing/web-platform/tests/progress-events/interface.html => testing/web-platform/tests/XMLHttpRequest/progressevent-interface.html rename : testing/web-platform/tests/cssom/MediaList.xhtml => testing/web-platform/tests/cssom/MediaList2.xhtml rename : testing/web-platform/tests/old-tests/submission/Microsoft/dragdrop/dragdrop_support.js => testing/web-platform/tests/html/editing/dnd/resources/dragdrop_support.js rename : testing/web-platform/tests/old-tests/submission/Microsoft/structuredclone/echo.js => testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/echo.js rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox_011.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/sandbox_011.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_002.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_002.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_003.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_003.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_006.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_006.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_007.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_007.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_012.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_012.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_023.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_023.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_024.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_024.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_028.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_028.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_029.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_029.htm rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox.pdf => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox.pdf rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/023.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/023.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/050.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/050.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/067.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/067.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/069.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/069.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/075.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/075.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/077.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/077.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/078.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/078.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/079.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/079.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/101.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/101.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-import.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-noimport.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-import.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-noimport.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/111.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/111.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/112.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/112.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/119.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/119.html rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/background.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/background.css rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/import.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/import.css rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/count-script-tags.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/count-script-tags.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-body.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-body.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-foo.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-foo.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-1.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-1.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-10.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-10.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-11.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-11.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-2.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-2.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-3.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-3.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-4.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-4.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-5.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-5.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-6.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-6.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-7.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-7.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-8.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-8.js rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-9.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-9.js rename : testing/web-platform/tests/assumptions/OWNERS => testing/web-platform/tests/infrastructure/assumptions/OWNERS rename : testing/web-platform/tests/assumptions/canvas-background-ref.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background-ref.html rename : testing/web-platform/tests/assumptions/canvas-background.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background.html rename : testing/web-platform/tests/assumptions/html-elements.html => testing/web-platform/tests/infrastructure/assumptions/html-elements.html rename : testing/web-platform/tests/assumptions/initial-color-ref.html => testing/web-platform/tests/infrastructure/assumptions/initial-color-ref.html rename : testing/web-platform/tests/assumptions/initial-color.html => testing/web-platform/tests/infrastructure/assumptions/initial-color.html rename : testing/web-platform/tests/assumptions/medium-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size-ref.html rename : testing/web-platform/tests/assumptions/medium-font-size.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size.html rename : testing/web-platform/tests/assumptions/min-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size-ref.html rename : testing/web-platform/tests/assumptions/min-font-size.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size.html rename : testing/web-platform/tests/assumptions/tools/build.sh => testing/web-platform/tests/infrastructure/assumptions/tools/build.sh rename : testing/web-platform/tests/infrastructure/failing-test.html => testing/web-platform/tests/infrastructure/expected-fail/failing-test.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html => testing/web-platform/tests/requestidlecallback/callback-exception.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-idle-periods.html => testing/web-platform/tests/requestidlecallback/callback-idle-periods.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html => testing/web-platform/tests/requestidlecallback/callback-iframe.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html => testing/web-platform/tests/requestidlecallback/callback-invoked.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html => testing/web-platform/tests/requestidlecallback/callback-multiple-calls.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-removed-frame.html => testing/web-platform/tests/requestidlecallback/callback-removed-frame.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout-with-raf.html => testing/web-platform/tests/requestidlecallback/callback-timeout-with-raf.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html => testing/web-platform/tests/requestidlecallback/callback-timeout.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-xhr-sync.html => testing/web-platform/tests/requestidlecallback/callback-xhr-sync.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html => testing/web-platform/tests/requestidlecallback/cancel-invoked.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html => testing/web-platform/tests/requestidlecallback/idlharness.html rename : testing/web-platform/tests/html/webappapis/idle-callbacks/resources/post_name_on_load.html => testing/web-platform/tests/requestidlecallback/resources/post_name_on_load.html rename : testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.html => testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.https.html rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.https.html rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.https.html rename : testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.https.html rename : testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.https.html rename : testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.https.html rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.https.html rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.https.html
		
			
				
	
	
		
			310 lines
		
	
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			310 lines
		
	
	
	
		
			11 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<!doctype html>
 | 
						|
<meta charset=utf-8>
 | 
						|
<title>RTCPeerConnection.prototype.removeTrack</title>
 | 
						|
<script src="/resources/testharness.js"></script>
 | 
						|
<script src="/resources/testharnessreport.js"></script>
 | 
						|
<script src="RTCPeerConnection-helper.js"></script>
 | 
						|
<script>
 | 
						|
  'use strict';
 | 
						|
 | 
						|
  // Test is based on the following editor draft:
 | 
						|
  // https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
 | 
						|
 | 
						|
  // The following helper functions are called from RTCPeerConnection-helper.js:
 | 
						|
  // generateAnswer
 | 
						|
  // generateMediaStreamTrack
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  RTCPeerConnection Interface Extensions
 | 
						|
      partial interface RTCPeerConnection {
 | 
						|
        ...
 | 
						|
        void                removeTrack(RTCRtpSender sender);
 | 
						|
        RTCRtpTransceiver   addTransceiver((MediaStreamTrack or DOMString) trackOrKind,
 | 
						|
                                                   optional RTCRtpTransceiverInit init);
 | 
						|
      };
 | 
						|
   */
 | 
						|
 | 
						|
  // Before calling removeTrack can be tested, one needs to add MediaStreamTracks to
 | 
						|
  // a peer connection. There are two ways for adding MediaStreamTrack: addTrack and
 | 
						|
  // addTransceiver. addTransceiver is a newer API while addTrack has been implemented
 | 
						|
  // in current browsers for some time. As a result some of the removeTrack tests have
 | 
						|
  // two versions so that removeTrack can be partially tested without addTransceiver
 | 
						|
  // and the transceiver APIs being implemented.
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      3.  If connection's [[isClosed]] slot is true, throw an InvalidStateError.
 | 
						|
   */
 | 
						|
  test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track);
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    pc.close();
 | 
						|
    assert_throws('InvalidStateError', () => pc.removeTrack(sender));
 | 
						|
 | 
						|
  }, 'addTransceiver - Calling removeTrack when connection is closed should throw InvalidStateError');
 | 
						|
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
 | 
						|
    return navigator.mediaDevices.getUserMedia({ audio: true })
 | 
						|
    .then(mediaStream => {
 | 
						|
      const tracks = mediaStream.getTracks();
 | 
						|
      assert_greater_than(tracks.length, 0,
 | 
						|
        'Expect getUserMedia to return at least one audio track');
 | 
						|
 | 
						|
      const track = tracks[0];
 | 
						|
      const sender = pc.addTrack(track, mediaStream);
 | 
						|
 | 
						|
      pc.close();
 | 
						|
      assert_throws('InvalidStateError', () => pc.removeTrack(sender));
 | 
						|
    });
 | 
						|
  }, 'addTrack - Calling removeTrack when connection is closed should throw InvalidStateError');
 | 
						|
 | 
						|
  test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track);
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    const pc2 = new RTCPeerConnection();
 | 
						|
    pc2.close();
 | 
						|
    assert_throws('InvalidStateError', () => pc2.removeTrack(sender));
 | 
						|
 | 
						|
  }, 'addTransceiver - Calling removeTrack on different connection that is closed should throw InvalidStateError');
 | 
						|
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
 | 
						|
    return navigator.mediaDevices.getUserMedia({ audio: true })
 | 
						|
    .then(mediaStream => {
 | 
						|
      const tracks = mediaStream.getTracks();
 | 
						|
      assert_greater_than(tracks.length, 0,
 | 
						|
        'Expect getUserMedia to return at least one audio track');
 | 
						|
 | 
						|
      const track = tracks[0];
 | 
						|
      const sender = pc.addTrack(track, mediaStream);
 | 
						|
 | 
						|
      const pc2 = new RTCPeerConnection();
 | 
						|
      pc2.close();
 | 
						|
      assert_throws('InvalidStateError', () => pc2.removeTrack(sender));
 | 
						|
    });
 | 
						|
  }, 'addTrack - Calling removeTrack on different connection that is closed should throw InvalidStateError');
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      4.  If sender was not created by connection, throw an InvalidAccessError.
 | 
						|
   */
 | 
						|
  test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track);
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    const pc2 = new RTCPeerConnection();
 | 
						|
    assert_throws('InvalidAccessError', () => pc2.removeTrack(sender));
 | 
						|
 | 
						|
  }, 'addTransceiver - Calling removeTrack on different connection should throw InvalidAccessError');
 | 
						|
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
 | 
						|
    return navigator.mediaDevices.getUserMedia({ audio: true })
 | 
						|
    .then(mediaStream => {
 | 
						|
      const tracks = mediaStream.getTracks();
 | 
						|
      assert_greater_than(tracks.length, 0,
 | 
						|
        'Expect getUserMedia to return at least one audio track');
 | 
						|
 | 
						|
      const track = tracks[0];
 | 
						|
      const sender = pc.addTrack(track, mediaStream);
 | 
						|
 | 
						|
      const pc2 = new RTCPeerConnection();
 | 
						|
      assert_throws('InvalidAccessError', () => pc2.removeTrack(sender));
 | 
						|
    });
 | 
						|
  }, 'addTrack - Calling removeTrack on different connection should throw InvalidAccessError')
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      7.  Set sender.track to null.
 | 
						|
   */
 | 
						|
  test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track);
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    assert_equals(sender.track, track);
 | 
						|
    assert_equals(transceiver.direction, 'sendrecv');
 | 
						|
    assert_equals(transceiver.currentDirection, null);
 | 
						|
 | 
						|
    pc.removeTrack(sender);
 | 
						|
    assert_equals(sender.track, null);
 | 
						|
    assert_equals(transceiver.direction, 'sendrecv',
 | 
						|
      'direction should not be altered');
 | 
						|
 | 
						|
  }, 'addTransceiver - Calling removeTrack with valid sender should set sender.track to null');
 | 
						|
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
 | 
						|
    return navigator.mediaDevices.getUserMedia({ audio: true })
 | 
						|
    .then(mediaStream => {
 | 
						|
      const tracks = mediaStream.getTracks();
 | 
						|
      assert_greater_than(tracks.length, 0,
 | 
						|
        'Expect getUserMedia to return at least one audio track');
 | 
						|
 | 
						|
      const track = tracks[0];
 | 
						|
      const sender = pc.addTrack(track, mediaStream);
 | 
						|
 | 
						|
      assert_equals(sender.track, track);
 | 
						|
 | 
						|
      pc.removeTrack(sender);
 | 
						|
      assert_equals(sender.track, null);
 | 
						|
    });
 | 
						|
  }, 'addTrack - Calling removeTrack with valid sender should set sender.track to null');
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      7.  Set sender.track to null.
 | 
						|
      10. If transceiver.currentDirection is sendrecv set transceiver.direction
 | 
						|
          to recvonly.
 | 
						|
   */
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track);
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    assert_equals(sender.track, track);
 | 
						|
    assert_equals(transceiver.direction, 'sendrecv');
 | 
						|
    assert_equals(transceiver.currentDirection, null);
 | 
						|
 | 
						|
    return pc.createOffer()
 | 
						|
    .then(offer =>
 | 
						|
      pc.setLocalDescription(offer)
 | 
						|
      .then(() => generateAnswer(offer)))
 | 
						|
    .then(answer => pc.setRemoteDescription(answer))
 | 
						|
    .then(() => {
 | 
						|
      assert_equals(transceiver.currentDirection, 'sendrecv');
 | 
						|
 | 
						|
      pc.removeTrack(sender);
 | 
						|
      assert_equals(sender.track, null);
 | 
						|
      assert_equals(transceiver.direction, 'recvonly');
 | 
						|
      assert_equals(transceiver.currentDirection, 'sendrecv',
 | 
						|
        'Expect currentDirection to not change');
 | 
						|
    });
 | 
						|
  }, 'Calling removeTrack with currentDirection sendrecv should set direction to recvonly');
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      7.  Set sender.track to null.
 | 
						|
      11. If transceiver.currentDirection is sendonly set transceiver.direction
 | 
						|
          to inactive.
 | 
						|
   */
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track, { direction: 'sendonly' });
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    assert_equals(sender.track, track);
 | 
						|
    assert_equals(transceiver.direction, 'sendonly');
 | 
						|
    assert_equals(transceiver.currentDirection, null);
 | 
						|
 | 
						|
    return pc.createOffer()
 | 
						|
    .then(offer =>
 | 
						|
      pc.setLocalDescription(offer)
 | 
						|
      .then(() => generateAnswer(offer)))
 | 
						|
    .then(answer => pc.setRemoteDescription(answer))
 | 
						|
    .then(() => {
 | 
						|
      assert_equals(transceiver.currentDirection, 'sendonly');
 | 
						|
 | 
						|
      pc.removeTrack(sender);
 | 
						|
      assert_equals(sender.track, null);
 | 
						|
      assert_equals(transceiver.direction, 'inactive');
 | 
						|
      assert_equals(transceiver.currentDirection, 'sendonly',
 | 
						|
        'Expect currentDirection to not change');
 | 
						|
    });
 | 
						|
  }, 'Calling removeTrack with currentDirection sendonly should set direction to inactive');
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      7.  Set sender.track to null.
 | 
						|
      9.  If transceiver.currentDirection is recvonly or inactive,
 | 
						|
          then abort these steps.
 | 
						|
   */
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track, { direction: 'recvonly' });
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    assert_equals(sender.track, track);
 | 
						|
    assert_equals(transceiver.direction, 'recvonly');
 | 
						|
    assert_equals(transceiver.currentDirection, null);
 | 
						|
 | 
						|
    return pc.createOffer()
 | 
						|
    .then(offer =>
 | 
						|
      pc.setLocalDescription(offer)
 | 
						|
      .then(() => generateAnswer(offer)))
 | 
						|
    .then(answer => pc.setRemoteDescription(answer))
 | 
						|
    .then(() => {
 | 
						|
      assert_equals(transceiver.currentDirection, 'recvonly');
 | 
						|
 | 
						|
      pc.removeTrack(sender);
 | 
						|
      assert_equals(sender.track, null);
 | 
						|
      assert_equals(transceiver.direction, 'recvonly');
 | 
						|
      assert_equals(transceiver.currentDirection, 'recvonly');
 | 
						|
    });
 | 
						|
  }, 'Calling removeTrack with currentDirection recvonly should not change direction');
 | 
						|
 | 
						|
  /*
 | 
						|
    5.1.  removeTrack
 | 
						|
      7.  Set sender.track to null.
 | 
						|
      9.  If transceiver.currentDirection is recvonly or inactive,
 | 
						|
          then abort these steps.
 | 
						|
   */
 | 
						|
  promise_test(t => {
 | 
						|
    const pc = new RTCPeerConnection();
 | 
						|
    const track = generateMediaStreamTrack('audio');
 | 
						|
    const transceiver = pc.addTransceiver(track, { direction: 'inactive' });
 | 
						|
    const { sender } = transceiver;
 | 
						|
 | 
						|
    assert_equals(sender.track, track);
 | 
						|
    assert_equals(transceiver.direction, 'inactive');
 | 
						|
    assert_equals(transceiver.currentDirection, null);
 | 
						|
 | 
						|
    return pc.createOffer()
 | 
						|
    .then(offer =>
 | 
						|
      pc.setLocalDescription(offer)
 | 
						|
      .then(() => generateAnswer(offer)))
 | 
						|
    .then(answer => pc.setRemoteDescription(answer))
 | 
						|
    .then(() => {
 | 
						|
      assert_equals(transceiver.currentDirection, 'inactive');
 | 
						|
 | 
						|
      pc.removeTrack(sender);
 | 
						|
      assert_equals(sender.track, null);
 | 
						|
      assert_equals(transceiver.direction, 'inactive');
 | 
						|
      assert_equals(transceiver.currentDirection, 'inactive');
 | 
						|
    });
 | 
						|
  }, 'Calling removeTrack with currentDirection inactive should not change direction');
 | 
						|
 | 
						|
  /*
 | 
						|
    TODO
 | 
						|
      5.1.  removeTrack
 | 
						|
        Stops sending media from sender. The RTCRtpSender will still appear
 | 
						|
        in getSenders. Doing so will cause future calls to createOffer to
 | 
						|
        mark the media description for the corresponding transceiver as
 | 
						|
        recvonly or inactive, as defined in [JSEP] (section 5.2.2.).
 | 
						|
 | 
						|
        When the other peer stops sending a track in this manner, an ended
 | 
						|
        event is fired at the MediaStreamTrack object.
 | 
						|
 | 
						|
        6.  If sender is not in senders (which indicates that it was removed
 | 
						|
            due to setting an RTCSessionDescription of type "rollback"),
 | 
						|
            then abort these steps.
 | 
						|
        12. Update the negotiation-needed flag for connection.
 | 
						|
   */
 | 
						|
</script>
 |