| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Copyright 2016 The Chromium Authors. All rights reserved. | 2 * Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Maps "RTCStats.type" values to descriptions of whitelisted (allowed to be | 8 * Maps "RTCStats.type" values to descriptions of whitelisted (allowed to be |
| 9 * exposed to the web) RTCStats-derived dictionaries described below. | 9 * exposed to the web) RTCStats-derived dictionaries described below. |
| 10 * @private | 10 * @private |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 verifyStatsIsWhitelisted_(stats); | 250 verifyStatsIsWhitelisted_(stats); |
| 251 statsTypes.add(stats.type); | 251 statsTypes.add(stats.type); |
| 252 if (ids.has(stats.id)) | 252 if (ids.has(stats.id)) |
| 253 throw failTest('stats.id is not a unique identifier.'); | 253 throw failTest('stats.id is not a unique identifier.'); |
| 254 ids.add(stats.id); | 254 ids.add(stats.id); |
| 255 } | 255 } |
| 256 returnToTest('ok-' + JSON.stringify(Array.from(statsTypes.values()))); | 256 returnToTest('ok-' + JSON.stringify(Array.from(statsTypes.values()))); |
| 257 }, | 257 }, |
| 258 function(e) { | 258 function(e) { |
| 259 throw failTest('Promise was rejected: ' + e); | 259 throw failTest('Promise was rejected: ' + e); |
| 260 }); | |
| 261 } | |
| 262 | |
| 263 /** | |
| 264 * Gets the result of the promise-based |RTCPeerConnection.getStats| as a | |
| 265 * dictionary of RTCStats-dictionaries. | |
| 266 * | |
| 267 * Returns "ok-" followed by a JSON-stringified dictionary of dictionaries to | |
| 268 * the test. | |
| 269 */ | |
| 270 function getStatsReportDictionary() { | |
| 271 peerConnection_().getStats() | |
| 272 .then(function(report) { | |
| 273 if (report == null || report.size == 0) | |
| 274 throw new failTest('report is null or empty.'); | |
| 275 let reportDictionary = {}; | |
| 276 for (let stats of report.values()) { | |
| 277 reportDictionary[stats.id] = stats; | |
| 278 } | |
| 279 returnToTest('ok-' + JSON.stringify(reportDictionary)); | |
| 280 }, | |
| 281 function(e) { | |
| 282 throw failTest('Promise was rejected: ' + e); | |
| 283 }); | 260 }); |
| 284 } | 261 } |
| 285 | 262 |
| 286 /** | 263 /** |
| 287 * Returns a complete list of whitelisted "RTCStats.type" values as a | 264 * Returns a complete list of whitelisted "RTCStats.type" values as a |
| 288 * JSON-stringified array of strings to the test. | 265 * JSON-stringified array of strings to the test. |
| 289 */ | 266 */ |
| 290 function getWhitelistedStatsTypes() { | 267 function getWhitelistedStatsTypes() { |
| 291 returnToTest(JSON.stringify(Array.from(gStatsWhitelist.keys()))); | 268 returnToTest(JSON.stringify(Array.from(gStatsWhitelist.keys()))); |
| 292 } | 269 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 if (typeof(element) !== elementType) { | 328 if (typeof(element) !== elementType) { |
| 352 throw failTest('stats.' + propertyName + ' should have a different ' + | 329 throw failTest('stats.' + propertyName + ' should have a different ' + |
| 353 'type according to the whitelist (an element of the array has ' + | 330 'type according to the whitelist (an element of the array has ' + |
| 354 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + | 331 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + |
| 355 ' vs ' + whitelistedStats[propertyName]); | 332 ' vs ' + whitelistedStats[propertyName]); |
| 356 } | 333 } |
| 357 } | 334 } |
| 358 } | 335 } |
| 359 } | 336 } |
| 360 } | 337 } |
| OLD | NEW |