Bug 1531448: Make pc.close() stop the tranceivers, transceiver.stop() throw if the PC is closed, and update some test code. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Fri, 08 Mar 2019 13:49:14 +0000
changeset 521192 b064bf107f89
parent 521191 041549532c29
child 521193 7f67893c6896
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1531448
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531448: Make pc.close() stop the tranceivers, transceiver.stop() throw if the PC is closed, and update some test code. r=jib Differential Revision: https://phabricator.services.mozilla.com/D22011
dom/media/PeerConnection.jsm
testing/web-platform/meta/webrtc/RTCPeerConnection-transceivers.https.html.ini
testing/web-platform/tests/webrtc/RTCRtpTransceiver.https.html
--- a/dom/media/PeerConnection.jsm
+++ b/dom/media/PeerConnection.jsm
@@ -1357,16 +1357,17 @@ class RTCPeerConnection {
     this._closed = true;
     this.changeIceConnectionState("closed");
     if (this._localIdp) {
         this._localIdp.close();
     }
     if (this._remoteIdp) {
         this._remoteIdp.close();
     }
+    this._transceivers.forEach(t => t.setStopped());
     this._impl.close();
     this._suppressEvents = true;
     delete this._pc;
     delete this._observer;
   }
 
   getLocalStreams() {
     this._checkClosed();
@@ -2261,22 +2262,22 @@ class RTCRtpTransceiver {
     return this._direction;
   }
 
   setDirectionInternal(direction) {
     this._direction = direction;
   }
 
   stop() {
+    this._pc._checkClosed();
+
     if (this.stopped) {
       return;
     }
 
-    this._pc._checkClosed();
-
     this.setStopped();
     this.sync();
     this._pc.updateNegotiationNeeded();
   }
 
   setStopped() {
     this.stopped = true;
     this.currentDirection = null;
--- a/testing/web-platform/meta/webrtc/RTCPeerConnection-transceivers.https.html.ini
+++ b/testing/web-platform/meta/webrtc/RTCPeerConnection-transceivers.https.html.ini
@@ -1,8 +1,4 @@
 [RTCPeerConnection-transceivers.https.html]
   [addTransceiver(track, init): initialize sendEncodings\[0\].active to false]
     expected: FAIL
     bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1396918
-
-  [Closing the PC stops the transceivers]
-    expected: FAIL
-    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1531448
--- a/testing/web-platform/tests/webrtc/RTCRtpTransceiver.https.html
+++ b/testing/web-platform/tests/webrtc/RTCRtpTransceiver.https.html
@@ -985,16 +985,19 @@
       [
         {
           track: pc2.getTransceivers()[0].receiver.track,
           streams: [{id: stream.id}]
         }
       ]);
 
     hasProps(pc2.getTransceivers(), [{currentDirection: "sendrecv"}]);
+
+    pc2.close();
+    hasProps(pc2.getTransceivers(), [{currentDirection: null}]);
   };
 
   const checkSendrecvWithNoSendTrack = async t => {
     const pc1 = new RTCPeerConnection();
     const pc2 = new RTCPeerConnection();
     t.add_cleanup(() => pc1.close());
     t.add_cleanup(() => pc2.close());
 
@@ -1272,18 +1275,20 @@
       ]);
 
     // Shouldn't throw either
     stoppedTransceiver.stop();
 
     pc1.close();
     pc2.close();
 
-    // Still shouldn't throw
-    stoppedTransceiver.stop();
+    // Spec says the closed check comes before the stopped check, so this
+    // should throw now.
+    checkThrows(() => stoppedTransceiver.stop(),
+                "InvalidStateError", "RTCRtpTransceiver.stop() with closed PC");
   };
 
   const checkStopAfterCreateOffer = async t => {
     const pc1 = new RTCPeerConnection();
     const pc2 = new RTCPeerConnection();
     t.add_cleanup(() => pc1.close());
     t.add_cleanup(() => pc2.close());