Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Unified Diff: chrome/test/data/webrtc/peerconnection_getstats.js

Issue 2363673002: Promise-based RTCPeerConnection::getStats implementation. (Closed)
Patch Set: RTCStatsReport.idl behind getStats-flag instead of updating virtual/stable/webexposed/global-interf… Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webrtc/peerconnection_getstats.js
diff --git a/chrome/test/data/webrtc/peerconnection_getstats.js b/chrome/test/data/webrtc/peerconnection_getstats.js
new file mode 100644
index 0000000000000000000000000000000000000000..9258a3656f768a57bb8905d10787190ccaa162a8
--- /dev/null
+++ b/chrome/test/data/webrtc/peerconnection_getstats.js
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2016 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+// Public interface to tests. These are expected to be called with
+// ExecuteJavascript invocations from the browser tests and will return answers
+// through the DOM automation controller.
+
+/**
+ * Verifies that the promise-based |RTCPeerConnection.getStats| returns stats.
+ *
+ * Returns ok-got-stats on success.
+ */
+function verifyStatsGeneratedPromise() {
+ peerConnection_().getStats()
+ .then(function(report) {
+ if (report == null || report.size == 0)
+ throw new failTest('report is null or empty.');
+ // Sanity check that applies to all stats.
+ var ids = new Set();
+ report.forEach(function(stats) {
+ if (typeof(stats.id) !== 'string')
+ throw failTest('stats.id is not a string.');
+ if (ids.has(stats.id))
+ throw failTest('stats.id is not a unique identifier.');
+ ids.add(stats.id);
+ if (typeof(stats.timestamp) !== 'number' || stats.timestamp <= 0)
+ throw failTest('stats.timestamp is not a positive number.');
+ if (typeof(stats.type) !== 'string')
+ throw failTest('stats.type is not a string.');
+ });
+ // TODO(hbos): When the new stats collection API is more mature (and
+ // certainly before unflagging the new stats API) add a whitelist of
+ // allowed stats to prevent accidentally exposing stats to the web that
+ // are not in the spec and that verifies type information. Status at
+ // crbug.com/627816. Stats collection is tested in the WebRTC repo and
+ // automatically surfaced to Blink, but there should be a process of
+ // having to land a Blink CL in order to expose a new RTCStats dictionary.
+ returnToTest('ok-got-stats');
+ },
+ function(e) {
+ throw failTest('Promise was rejected: ' + e);
+ });
+}
« no previous file with comments | « chrome/browser/media/webrtc/webrtc_browsertest_base.cc ('k') | chrome/test/data/webrtc/webrtc_jsep01_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698