OLD | NEW |
(Empty) | |
| 1 /** |
| 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 |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 // Public interface to tests. These are expected to be called with |
| 8 // ExecuteJavascript invocations from the browser tests and will return answers |
| 9 // through the DOM automation controller. |
| 10 |
| 11 /** |
| 12 * Verifies that the promise-based |RTCPeerConnection.getStats| returns stats. |
| 13 * |
| 14 * Returns ok-got-stats on success. |
| 15 */ |
| 16 function verifyStatsGeneratedPromise() { |
| 17 peerConnection_().getStats() |
| 18 .then(function(report) { |
| 19 if (report == null || report.size == 0) |
| 20 throw new failTest('report is null or empty.'); |
| 21 // Sanity check that applies to all stats. |
| 22 var ids = new Set(); |
| 23 report.forEach(function(stats) { |
| 24 if (typeof(stats.id) !== 'string') |
| 25 throw failTest('stats.id is not a string.'); |
| 26 if (ids.has(stats.id)) |
| 27 throw failTest('stats.id is not a unique identifier.'); |
| 28 ids.add(stats.id); |
| 29 if (typeof(stats.timestamp) !== 'number' || stats.timestamp <= 0) |
| 30 throw failTest('stats.timestamp is not a positive number.'); |
| 31 if (typeof(stats.type) !== 'string') |
| 32 throw failTest('stats.type is not a string.'); |
| 33 }); |
| 34 // TODO(hbos): When the new stats collection API is more mature (and |
| 35 // certainly before unflagging the new stats API) add a whitelist of |
| 36 // allowed stats to prevent accidentally exposing stats to the web that |
| 37 // are not in the spec and that verifies type information. Status at |
| 38 // crbug.com/627816. Stats collection is tested in the WebRTC repo and |
| 39 // automatically surfaced to Blink, but there should be a process of |
| 40 // having to land a Blink CL in order to expose a new RTCStats dictionary. |
| 41 returnToTest('ok-got-stats'); |
| 42 }, |
| 43 function(e) { |
| 44 throw failTest('Promise was rejected: ' + e); |
| 45 }); |
| 46 } |
OLD | NEW |