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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 }); | 260 }); |
261 } | 261 } |
262 | 262 |
263 /** | 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 }); |
| 284 } |
| 285 |
| 286 /** |
264 * Returns a complete list of whitelisted "RTCStats.type" values as a | 287 * Returns a complete list of whitelisted "RTCStats.type" values as a |
265 * JSON-stringified array of strings to the test. | 288 * JSON-stringified array of strings to the test. |
266 */ | 289 */ |
267 function getWhitelistedStatsTypes() { | 290 function getWhitelistedStatsTypes() { |
268 returnToTest(JSON.stringify(Array.from(gStatsWhitelist.keys()))); | 291 returnToTest(JSON.stringify(Array.from(gStatsWhitelist.keys()))); |
269 } | 292 } |
270 | 293 |
271 // Internals. | 294 // Internals. |
272 | 295 |
273 /** @private */ | 296 /** @private */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 if (typeof(element) !== elementType) { | 351 if (typeof(element) !== elementType) { |
329 throw failTest('stats.' + propertyName + ' should have a different ' + | 352 throw failTest('stats.' + propertyName + ' should have a different ' + |
330 'type according to the whitelist (an element of the array has ' + | 353 'type according to the whitelist (an element of the array has ' + |
331 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + | 354 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + |
332 ' vs ' + whitelistedStats[propertyName]); | 355 ' vs ' + whitelistedStats[propertyName]); |
333 } | 356 } |
334 } | 357 } |
335 } | 358 } |
336 } | 359 } |
337 } | 360 } |
OLD | NEW |