Bug 1418522 - fix unmatched ICE candidate handling on about:webrtc. r?ng draft
authorMichael Froman <mfroman@mozilla.com>
Fri, 17 Nov 2017 17:08:00 -0600
changeset 700763 8e6c3db08afe5bc3ea147f1f843e2565c5f5f56b
parent 700056 daa0dcd1616cbdf5541f548e44662d20d6d67d99
child 740997 f1ae8889c8a2e7226db9e50f9ebdf9a284e5fb83
push id89969
push userbmo:mfroman@nostrum.com
push dateMon, 20 Nov 2017 22:00:01 +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 "*";
     }