function verifyStatsIsWhitelisted_(stats) {
  if (stats == null)
    throw failTest('stats is null or undefined: ' + stats);
  if (typeof(stats.id) !== 'string')
    throw failTest('stats.id is not a string:' + stats.id);
  if (typeof(stats.timestamp) !== 'number' || !isFinite(stats.timestamp) ||
      stats.timestamp <= 0) {
    throw failTest('stats.timestamp is not a positive finite number: ' +
        stats.timestamp);
  }
  if (typeof(stats.type) !== 'string')
    throw failTest('stats.type is not a string: ' + stats.type);
  let whitelistedStats = gStatsWhitelist.get(stats.type);
  if (whitelistedStats == null)
    throw failTest('stats.type is not a whitelisted type: ' + stats.type);
  for (let propertyName in stats) {
    if (propertyName === 'id' || propertyName === 'timestamp' ||
        propertyName === 'type') {
      continue;
    }
    if (!whitelistedStats.hasOwnProperty(propertyName)) {
      throw failTest('stats.' + propertyName + ' is not a whitelisted ' +
          'member: ' + stats[propertyName]);
    }
    if (whitelistedStats[propertyName] === 'any')
      continue;
    if (!whitelistedStats[propertyName].startsWith('sequence_')) {
      if (typeof(stats[propertyName]) !== whitelistedStats[propertyName]) {
        throw failTest('stats.' + propertyName + ' should have a different ' +
            'type according to the whitelist: ' + stats[propertyName] + ' vs ' +
            whitelistedStats[propertyName]);
      }
    } else {
      if (!Array.isArray(stats[propertyName])) {
        throw failTest('stats.' + propertyName + ' should have a different ' +
            'type according to the whitelist (should be an array): ' +
            JSON.stringify(stats[propertyName]) + ' vs ' +
            whitelistedStats[propertyName]);
      }
      let elementType = whitelistedStats[propertyName].substring(9);
      for (let element in stats[propertyName]) {
        if (typeof(element) !== elementType) {
          throw failTest('stats.' + propertyName + ' should have a different ' +
              'type according to the whitelist (an element of the array has ' +
              'the incorrect type): ' + JSON.stringify(stats[propertyName]) +
              ' vs ' + whitelistedStats[propertyName]);
        }
      }
    }
  }
}
/**
 * Checks if |stats| correctly maps to a a whitelisted RTCStats-derived
 * dictionary, throwing |failTest| if it doesn't. See |gStatsWhitelist|.
 *
 * The "RTCStats.type" must map to a known dictionary description. Every member
 * is optional, but if present it must be present in the whitelisted dictionary
 * description and its type must match.
 * @private
 */
Checks if |stats| correctly maps to a a whitelisted RTCStats-derived
dictionary, throwing |failTest| if it doesn't.

The "RTCStats.type" must map to a known dictionary description. Every member
is optional, but if present it must be present in the whitelisted dictionary
description and its type must match.
@private
Checks if |stats| correctly maps to a a whitelisted RTCStats - derived dictionary throwing |failTest| if it doesn ' t . The " RTCStats . type " must map to a known dictionary description . Every member is optional but if present it must be present in the whitelisted dictionary description and its type must match . @private
function verifyStatsIsWhitelisted_(stats) {
  if (stats == null)
    throw failTest('stats is null or undefined: ' + stats);
  if (typeof(stats.id) !== 'string')
    throw failTest('stats.id is not a string:' + stats.id);
  if (typeof(stats.timestamp) !== 'number' || !isFinite(stats.timestamp) ||
      stats.timestamp <= 0) {
    throw failTest('stats.timestamp is not a positive finite number: ' +
        stats.timestamp);
  }
  if (typeof(stats.type) !== 'string')
    throw failTest('stats.type is not a string: ' + stats.type);
  let whitelistedStats = gStatsWhitelist.get(stats.type);
  if (whitelistedStats == null)
    throw failTest('stats.type is not a whitelisted type: ' + stats.type);
  for (let propertyName in stats) {
    if (propertyName === 'id' || propertyName === 'timestamp' ||
        propertyName === 'type') {
      continue;
    }
    if (!whitelistedStats.hasOwnProperty(propertyName)) {
      throw failTest('stats.' + propertyName + ' is not a whitelisted ' +
          'member: ' + stats[propertyName]);
    }
    if (whitelistedStats[propertyName] === 'any')
      continue;
    if (!whitelistedStats[propertyName].startsWith('sequence_')) {
      if (typeof(stats[propertyName]) !== whitelistedStats[propertyName]) {
        throw failTest('stats.' + propertyName + ' should have a different ' +
            'type according to the whitelist: ' + stats[propertyName] + ' vs ' +
            whitelistedStats[propertyName]);
      }
    } else {
      if (!Array.isArray(stats[propertyName])) {
        throw failTest('stats.' + propertyName + ' should have a different ' +
            'type according to the whitelist (should be an array): ' +
            JSON.stringify(stats[propertyName]) + ' vs ' +
            whitelistedStats[propertyName]);
      }
      let elementType = whitelistedStats[propertyName].substring(9);
      for (let element in stats[propertyName]) {
        if (typeof(element) !== elementType) {
          throw failTest('stats.' + propertyName + ' should have a different ' +
              'type according to the whitelist (an element of the array has ' +
              'the incorrect type): ' + JSON.stringify(stats[propertyName]) +
              ' vs ' + whitelistedStats[propertyName]);
        }
      }
    }
  }
}
function verifyStatsIsWhitelisted_ ( stats ) { if ( stats == null ) throw failTest ( 'stats is null or undefined: ' + stats ) ; if ( typeof ( stats . id ) !== 'string' ) throw failTest ( 'stats.id is not a string:' + stats . id ) ; if ( typeof ( stats . timestamp ) !== 'number' || ! isFinite ( stats . timestamp ) || stats . timestamp <= 0 ) { throw failTest ( 'stats.timestamp is not a positive finite number: ' + stats . timestamp ) ; } if ( typeof ( stats . type ) !== 'string' ) throw failTest ( 'stats.type is not a string: ' + stats . type ) ; let whitelistedStats = gStatsWhitelist . get ( stats . type ) ; if ( whitelistedStats == null ) throw failTest ( 'stats.type is not a whitelisted type: ' + stats . type ) ; for ( let propertyName in stats ) { if ( propertyName === 'id' || propertyName === 'timestamp' || propertyName === 'type' ) { continue ; } if ( ! whitelistedStats . hasOwnProperty ( propertyName ) ) { throw failTest ( 'stats.' + propertyName + ' is not a whitelisted ' + 'member: ' + stats [ propertyName ] ) ; } if ( whitelistedStats [ propertyName ] === 'any' ) continue ; if ( ! whitelistedStats [ propertyName ] . startsWith ( 'sequence_' ) ) { if ( typeof ( stats [ propertyName ] ) !== whitelistedStats [ propertyName ] ) { throw failTest ( 'stats.' + propertyName + ' should have a different ' + 'type according to the whitelist: ' + stats [ propertyName ] + ' vs ' + whitelistedStats [ propertyName ] ) ; } } else { if ( ! Array . isArray ( stats [ propertyName ] ) ) { throw failTest ( 'stats.' + propertyName + ' should have a different ' + 'type according to the whitelist (should be an array): ' + JSON . stringify ( stats [ propertyName ] ) + ' vs ' + whitelistedStats [ propertyName ] ) ; } let elementType = whitelistedStats [ propertyName ] . substring ( 9 ) ; for ( let element in stats [ propertyName ] ) { if ( typeof ( element ) !== elementType ) { throw failTest ( 'stats.' + propertyName + ' should have a different ' + 'type according to the whitelist (an element of the array has ' + 'the incorrect type): ' + JSON . stringify ( stats [ propertyName ] ) + ' vs ' + whitelistedStats [ propertyName ] ) ; } } } } }
Checks if |stats| correctly maps to a a whitelisted RTCStats-derived
 dictionary, throwing |failTest| if it doesn't.
Checks if |stats| correctly maps to a a whitelisted RTCStats - derived dictionary throwing |failTest| if it doesn ' t .