Bug 1523562 [wpt PR 15021] - Adds getStats() method to RTCQuicTransport., a=testonly
authorSeth Hampson <shampson@chromium.org>
Thu, 31 Jan 2019 18:59:51 +0000
changeset 458102 33368bf84956cb79c2d85e318a96e4845af071db
parent 458101 ff66c85a281440348e2ecced2ce7750820302296
child 458103 e6ab8078a445b3f354e63f31ba6282469ffb2e91
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1523562, 15021, 874296, 1430599, 625524
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1523562 [wpt PR 15021] - Adds getStats() method to RTCQuicTransport., a=testonly Automatic update from web-platform-tests Adds getStats() method to RTCQuicTransport. getStats() returns a promise that resolves with a dictionary of stats defined in the RTCQuicTransportStats dictionary. Bug: 874296 Change-Id: I907e529ebf074842c6702df7d90349515c48a5ba Reviewed-on: https://chromium-review.googlesource.com/c/1430599 Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Steve Anton <steveanton@chromium.org> Commit-Queue: Seth Hampson <shampson@chromium.org> Cr-Commit-Position: refs/heads/master@{#625524} -- wpt-commits: 72fa242727cb8e3515df9b4af598a43431faa10e wpt-pr: 15021
testing/web-platform/tests/webrtc-quic/RTCQuicTransport.https.html
--- a/testing/web-platform/tests/webrtc-quic/RTCQuicTransport.https.html
+++ b/testing/web-platform/tests/webrtc-quic/RTCQuicTransport.https.html
@@ -1,31 +1,33 @@
 <!doctype html>
 <meta charset=utf-8>
 <title>RTCQuicTransport.https.html</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="../webrtc/RTCIceTransport-extension-helper.js"></script>
 <script src="RTCQuicTransport-helper.js"></script>
+<script src="../webrtc/dictionary-helper.js"></script>
 <script>
 'use strict';
 
 // These tests are based on the following specification:
 // https://w3c.github.io/webrtc-quic/
 
 // The following helper functions are called from
 // RTCIceTransport-extension-helper.js:
 //   makeIceTransport
 //   makeAndGatherTwoIceTransports
 
 // The following helper functions are called from RTCQuicTransport-helper.js:
 //   makeQuicTransport
 //   makeStandaloneQuicTransport
 //   makeAndStartTwoQuicTransports
 //   makeTwoConnectedQuicTransports
+//   sleep
 
 test(t => {
   const iceTransport = makeIceTransport(t);
   const quicTransport = makeQuicTransport(t, iceTransport);
   assert_equals(quicTransport.transport, iceTransport,
       'Expect transport to be the same as the one passed in the constructor.');
   assert_equals(quicTransport.state, 'new', `Expect state to be 'new'.`);
 }, 'RTCQuicTransport initial properties are set.');
@@ -169,10 +171,98 @@ test(t => {
   let update_key = new Uint8Array(key);
   for (let i = 0; i < update_key.length; i++) {
     update_key[i] = 0;
   }
   const new_key = quicTransport.getKey();
   assert_not_equals(update_key, new Uint8Array(new_key));
 }, 'Cannot mutate key retrieved from getKey().');
 
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      makeAndStartTwoQuicTransports(t);
+  const stats = await localQuicTransport.getStats();
+  assert_number_field(stats, 'timestamp');
+  assert_unsigned_int_field(stats, 'bytesSent');
+  assert_unsigned_int_field(stats, 'packetsSent');
+  assert_unsigned_int_field(stats, 'streamBytesSent');
+  assert_unsigned_int_field(stats, 'streamBytesReceived');
+  assert_unsigned_int_field(stats, 'numOutgoingStreamsCreated');
+  assert_unsigned_int_field(stats, 'numIncomingStreamsCreated');
+  assert_unsigned_int_field(stats, 'bytesReceived');
+  assert_unsigned_int_field(stats, 'packetsReceived');
+  assert_unsigned_int_field(stats, 'packetsProcessed');
+  assert_unsigned_int_field(stats, 'bytesRetransmitted');
+  assert_unsigned_int_field(stats, 'packetsRetransmitted');
+  assert_unsigned_int_field(stats, 'packetsLost');
+  assert_unsigned_int_field(stats, 'packetsDropped');
+  assert_unsigned_int_field(stats, 'cryptoRetransmitCount');
+  assert_unsigned_int_field(stats, 'minRttUs');
+  assert_unsigned_int_field(stats, 'smoothedRttUs');
+  assert_unsigned_int_field(stats, 'maxPacketSize');
+  assert_unsigned_int_field(stats, 'maxReceivedPacketSize');
+  assert_unsigned_int_field(stats, 'estimatedBandwidthBps');
+  assert_unsigned_int_field(stats, 'packetsReordered');
+  assert_unsigned_int_field(stats, 'blockedFramesReceived');
+  assert_unsigned_int_field(stats, 'blockedFramesSent');
+  assert_unsigned_int_field(stats, 'connectivityProbingPacketsReceived');
+}, 'Stats returned by getStats() are present.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.write({ finish: true });
+  const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
+  await remoteWatcher.wait_for('quicstream');
+  const localStats = await localQuicTransport.getStats();
+  const remoteStats = await remoteQuicTransport.getStats();
+  assert_equals(localStats.numOutgoingStreamsCreated, 1);
+  assert_equals(localStats.numIncomingStreamsCreated, 0);
+  assert_equals(remoteStats.numOutgoingStreamsCreated, 0);
+  assert_equals(remoteStats.numIncomingStreamsCreated, 1);
+}, 'getStats() returns proper stream counts after creating streams.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      makeAndStartTwoQuicTransports(t);
+  const stats1 = await localQuicTransport.getStats();
+  await new Promise(resolve => t.step_timeout(resolve, 20));
+  const stats2 = await localQuicTransport.getStats();
+  assert_greater_than(stats2.timestamp, stats1.timestamp);
+}, 'Two separate stats returned by getStats() give different timestamps.');
+
+promise_test(async t => {
+  const quicTransport = makeStandaloneQuicTransport(t);
+  const promise = quicTransport.getStats();
+  promise_rejects(t, 'InvalidStateError', promise);
+}, 'getStats() promises immediately rejected with InvalidStateError ' +
+    `if called before 'connecting'.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const promise = localQuicTransport.getStats();
+  localQuicTransport.stop();
+  promise_rejects(t, 'InvalidStateError', promise);
+}, 'getStats() promises rejected  with InvalidStateError if stop() ' +
+   'is called before being fulfilled.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const promise = localQuicTransport.getStats();
+  localQuicTransport.transport.stop();
+  promise_rejects(t, 'InvalidStateError', promise);
+}, 'getStats() promises rejected  with InvalidStateError if ' +
+   'RTCIceTransport calls stop() before being fulfilled.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  localQuicTransport.transport.stop();
+  const promise = localQuicTransport.getStats();
+  promise_rejects(t, 'InvalidStateError', promise);
+}, 'getStats() promises immediately rejected if called after' +
+   `'closed' state.`);
+
 </script>