Bug 1418522 - fix unmatched ICE candidate handling on about:webrtc. r?ng
MozReview-Commit-ID: 4cbxgJw9xIF
--- 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 "*";
}