Issue #2332 - Hyphenate rtc stats type as per spec

Backport of https://bugzilla.mozilla.org/show_bug.cgi?id=1322503
This commit is contained in:
Basilisk-Dev 2023-10-18 16:30:27 -04:00 committed by roytam1
commit 9f63203a43
7 changed files with 57 additions and 42 deletions

View file

@ -308,13 +308,20 @@ RTCStatsReport.prototype = {
// Since maplike is recent, we still also make the stats available as legacy
// enumerable read-only properties directly on our content-facing object.
// Must be called after our webidl sandwich is made.
_specToLegacyFieldMapping: {
'inbound-rtp' : 'inboundrtp',
'outbound-rtp':'outboundrtp',
'candidate-pair':'candidatepair',
'local-candidate':'localcandidate',
'remote-candidate':'remotecandidate'
},
makeStatsPublic: function(warnNullable) {
let legacyProps = {};
for (let key in this._report) {
this.setInternal(key, Cu.cloneInto(this._report[key], this._win));
let value = Cu.cloneInto(this._report[key], this._win);
this.setInternal(key, value);
value.type = this._specToLegacyFieldMapping[value.type] || value.type;
legacyProps[key] = {
enumerable: true, configurable: false,
get: Cu.exportFunction(function() {