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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 reportDictionary[stats.id] = stats; | 294 reportDictionary[stats.id] = stats; |
295 } | 295 } |
296 returnToTest('ok-' + JSON.stringify(reportDictionary)); | 296 returnToTest('ok-' + JSON.stringify(reportDictionary)); |
297 }, | 297 }, |
298 function(e) { | 298 function(e) { |
299 throw failTest('Promise was rejected: ' + e); | 299 throw failTest('Promise was rejected: ' + e); |
300 }); | 300 }); |
301 } | 301 } |
302 | 302 |
303 /** | 303 /** |
| 304 * Measures the performance of the promise-based |RTCPeerConnection.getStats| |
| 305 * and returns the time it took in milliseconds as a double |
| 306 * (DOMHighResTimeStamp, accurate to one thousandth of a millisecond). |
| 307 * Verifies that all stats types of the whitelist were contained in the result. |
| 308 * |
| 309 * Returns "ok-" followed by a double on success. |
| 310 */ |
| 311 function measureGetStatsPerformance() { |
| 312 let t0 = performance.now(); |
| 313 peerConnection_().getStats() |
| 314 .then(function(report) { |
| 315 let t1 = performance.now(); |
| 316 let statsTypes = new Set(); |
| 317 for (let stats of report.values()) { |
| 318 verifyStatsIsWhitelisted_(stats); |
| 319 statsTypes.add(stats.type); |
| 320 } |
| 321 if (statsTypes.size != gStatsWhitelist.size) { |
| 322 returnToTest('The returned report contains a different number (' + |
| 323 statsTypes.size + ') of stats types than the whitelist. ' + |
| 324 JSON.stringify(Array.from(statsTypes))); |
| 325 } |
| 326 returnToTest('ok-' + (t1 - t0)); |
| 327 }, |
| 328 function(e) { |
| 329 throw failTest('Promise was rejected: ' + e); |
| 330 }); |
| 331 } |
| 332 |
| 333 /** |
304 * Returns a complete list of whitelisted "RTCStats.type" values as a | 334 * Returns a complete list of whitelisted "RTCStats.type" values as a |
305 * JSON-stringified array of strings to the test. | 335 * JSON-stringified array of strings to the test. |
306 */ | 336 */ |
307 function getWhitelistedStatsTypes() { | 337 function getWhitelistedStatsTypes() { |
308 returnToTest(JSON.stringify(Array.from(gStatsWhitelist.keys()))); | 338 returnToTest(JSON.stringify(Array.from(gStatsWhitelist.keys()))); |
309 } | 339 } |
310 | 340 |
311 // Internals. | 341 // Internals. |
312 | 342 |
313 /** @private */ | 343 /** @private */ |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 if (typeof(element) !== elementType) { | 398 if (typeof(element) !== elementType) { |
369 throw failTest('stats.' + propertyName + ' should have a different ' + | 399 throw failTest('stats.' + propertyName + ' should have a different ' + |
370 'type according to the whitelist (an element of the array has ' + | 400 'type according to the whitelist (an element of the array has ' + |
371 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + | 401 'the incorrect type): ' + JSON.stringify(stats[propertyName]) + |
372 ' vs ' + whitelistedStats[propertyName]); | 402 ' vs ' + whitelistedStats[propertyName]); |
373 } | 403 } |
374 } | 404 } |
375 } | 405 } |
376 } | 406 } |
377 } | 407 } |
OLD | NEW |