Bug 1418522 - fix unmatched ICE candidate handling on about:webrtc. r=ng
authorMichael Froman <mfroman@mozilla.com>
Fri, 17 Nov 2017 17:08:00 -0600
changeset 437319 ff6ab6ec5d185be0a27a7779dbf82e991fe4de59
parent 437318 82ea4b82a7fa6fe300c86f2306a8b803087f78eb
child 437320 5f6fb7f92a7cf07c18a02c0f3ca12d65d8a40bcd
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersng
bugs1418522
milestone59.0a1
Bug 1418522 - fix unmatched ICE candidate handling on about:webrtc. r=ng MozReview-Commit-ID: 4cbxgJw9xIF
toolkit/content/aboutwebrtc/aboutWebrtc.js
--- a/toolkit/content/aboutwebrtc/aboutWebrtc.js
+++ b/toolkit/content/aboutwebrtc/aboutWebrtc.js
@@ -660,18 +660,18 @@ function ICEStats(report) {
   this._report = report;
 }
 
 ICEStats.prototype = {
   render() {
     let tbody = [];
     for (let stat of this.generateICEStats()) {
       tbody.push([
-        stat.localcandidate || "",
-        stat.remotecandidate || "",
+        stat["local-candidate"] || "",
+        stat["remote-candidate"] || "",
         stat.state || "",
         stat.priority || "",
         stat.nominated || "",
         stat.selected || "",
         stat.bytesSent || "",
         stat.bytesReceived || ""
       ]);
     }
@@ -728,42 +728,38 @@ ICEStats.prototype = {
     let stat;
 
     for (let pair of this._report.iceCandidatePairStats) {
       let local = candidates.get(pair.localCandidateId);
       let remote = candidates.get(pair.remoteCandidateId);
 
       if (local) {
         stat = {
-          localcandidate: this.candidateToString(local),
+          ["local-candidate"]: this.candidateToString(local),
           state: pair.state,
           priority: pair.priority,
           nominated: pair.nominated,
           selected: pair.selected,
           bytesSent: pair.bytesSent,
           bytesReceived: pair.bytesReceived
         };
         matched[local.id] = true;
 
         if (remote) {
-          stat.remotecandidate = this.candidateToString(remote);
+          stat["remote-candidate"] = this.candidateToString(remote);
           matched[remote.id] = true;
         }
         stats.push(stat);
       }
     }
 
-    for (let c of candidates.values()) {
-      if (matched[c.id])
-        continue;
-
-      stat = {};
-      stat[c.type] = this.candidateToString(c);
-      stats.push(stat);
-    }
+    // add the unmatched candidates to the end of the table
+    [...candidates.values()].filter(cand => !matched[cand.id]).forEach(
+      cand => stats.push({[cand.type]: this.candidateToString(cand)})
+    );
 
     return stats.sort((a, b) => (b.priority || 0) - (a.priority || 0));
   },
 
   candidateToString(c) {
     if (!c) {
       return "*";
     }