Bug 1531084 - Part 1: Implement selector checking according to spec. r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Wed, 13 Mar 2019 20:59:24 +0000
changeset 521787 5f68ff0281ce
parent 521786 fec14f7cec4a
child 521788 483937099277
push id10867
push userdvarga@mozilla.com
push dateThu, 14 Mar 2019 15:20:45 +0000
treeherdermozilla-beta@abad13547875 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1531084
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 1531084 - Part 1: Implement selector checking according to spec. r=jib Depends on D23052 Differential Revision: https://phabricator.services.mozilla.com/D23053
dom/media/PeerConnection.jsm
--- a/dom/media/PeerConnection.jsm
+++ b/dom/media/PeerConnection.jsm
@@ -1532,20 +1532,36 @@ class RTCPeerConnection {
     if (state != this._iceConnectionState) {
       this._iceConnectionState = state;
       _globalPCList.notifyLifecycleObservers(this, "iceconnectionstatechange");
       this.dispatchEvent(new this._win.Event("iceconnectionstatechange"));
     }
   }
 
   getStats(selector, onSucc, onErr) {
+    if (selector !== null) {
+      let matchingSenders =
+        this.getSenders().filter(s => s.track === selector);
+      let matchingReceivers =
+        this.getReceivers().filter(r => r.track === selector);
+
+      if (matchingSenders.length + matchingReceivers.length != 1) {
+        throw new this._win.DOMException(
+            "track must be associated with a unique sender or receiver, but "
+            + " is associated with " + matchingSenders.length
+            + " senders and " + matchingReceivers.length + " receivers.",
+            "InvalidAccessError");
+      }
+    }
+
     if (this._iceConnectionState === "completed" ||
         this._iceConnectionState === "connected") {
       this._pcTelemetry.recordGetStats();
     }
+
     return this._auto(onSucc, onErr, () => this._getStats(selector));
   }
 
   async _getStats(selector) {
     // getStats is allowed even in closed state.
     return this._chain(() => new Promise((resolve, reject) => {
       this._onGetStatsSuccess = resolve;
       this._onGetStatsFailure = reject;