Bug 1495477 [wpt PR 13287] - Implement RTCQuicTransport.onquicstream and stream reset/finish, a=testonly
authorSteve Anton <steveanton@chromium.org>
Tue, 09 Oct 2018 04:13:12 +0000
changeset 495932 ec2733b0a08fcfed54c2f0dfd344036900ac1e4b
parent 495931 578584d3e8e54f6080253acc575231460ca17e0c
child 495933 daf57bccbbdcb3067db8c4883e85a509949c3225
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1495477, 13287, 874296, 1217846, 596068
milestone64.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 1495477 [wpt PR 13287] - Implement RTCQuicTransport.onquicstream and stream reset/finish, a=testonly Automatic update from web-platform-testsImplement RTCQuicTransport.onquicstream and stream reset/finish This CL implements the RTCQuicTransport createStream method and the corresponding quicstream event hooked up to the QUIC adapters. It also implements RTCQuicStream.reset/finish and statechange event to allow end-to-end testing. Bug: 874296 Change-Id: I331d37f3e21c606697b8768bf9eea59c90487163 Reviewed-on: https://chromium-review.googlesource.com/c/1217846 Commit-Queue: Steve Anton <steveanton@chromium.org> Reviewed-by: Kentaro Hara <haraken@chromium.org> Reviewed-by: Henrik Boström <hbos@chromium.org> Cr-Commit-Position: refs/heads/master@{#596068} -- wpt-commits: 2625aa78ed1abccb12cde20af2b5d6650a407cf6 wpt-pr: 13287
testing/web-platform/tests/webrtc/RTCQuicStream.https.html
testing/web-platform/tests/webrtc/RTCQuicTransport-helper.js
testing/web-platform/tests/webrtc/RTCQuicTransport.https.html
--- a/testing/web-platform/tests/webrtc/RTCQuicStream.https.html
+++ b/testing/web-platform/tests/webrtc/RTCQuicStream.https.html
@@ -8,37 +8,151 @@
 <script>
 'use strict';
 
 // These tests are based on the following specification:
 // https://w3c.github.io/webrtc-quic/
 
 // The following helper functions are called from RTCQuicTransport-helper.js:
 //   makeStandaloneQuicTransport
+//   makeTwoConnectedQuicTransports
 
 promise_test(async t => {
-  const quicTransport = await makeStandaloneQuicTransport(t);
+  const [ quicTransport, ] = await makeTwoConnectedQuicTransports(t);
   const quicStream = quicTransport.createStream();
   assert_equals(quicStream.transport, quicTransport,
       'Expect transport to be set to the creating RTCQuicTransport.');
-  assert_equals(quicStream.state, 'new', `Expect state to be 'new'.`);
+  assert_equals(quicStream.state, 'open', `Expect state to be 'open'.`);
   assert_equals(quicStream.readBufferedAmount, 0,
       'Expect read buffered amount to be 0.');
   assert_equals(quicStream.writeBufferedAmount, 0,
       'Expect write buffered amount to be 0.');
 }, 'createStream() returns an RTCQuicStream with initial properties set.');
 
 promise_test(async t => {
   const quicTransport = await makeStandaloneQuicTransport(t);
+  assert_throws('InvalidStateError', () => quicTransport.createStream());
+}, 'createStream() throws if the transport is not connected.');
+
+promise_test(async t => {
+  const quicTransport = await makeStandaloneQuicTransport(t);
   quicTransport.stop();
   assert_throws('InvalidStateError', () => quicTransport.createStream());
 }, 'createStream() throws if the transport is closed.');
 
 promise_test(async t => {
-  const quicTransport = await makeStandaloneQuicTransport(t);
+  const [ quicTransport, ] = await makeTwoConnectedQuicTransports(t);
   const firstQuicStream = quicTransport.createStream();
   const secondQuicStream = quicTransport.createStream();
   quicTransport.stop();
   assert_equals(firstQuicStream.state, 'closed');
   assert_equals(secondQuicStream.state, 'closed');
-}, 'RTCQuicTransport.stop() closes all streams.');
+}, 'RTCQuicTransport.stop() closes all local streams.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const firstLocalStream = localQuicTransport.createStream();
+  firstLocalStream.finish();
+  const secondLocalStream = localQuicTransport.createStream();
+  secondLocalStream.finish();
+  const remoteWatcher =
+      new EventWatcher(t, remoteQuicTransport, [ 'quicstream', 'statechange' ]);
+  const { stream: firstRemoteStream } =
+      await remoteWatcher.wait_for('quicstream');
+  const { stream: secondRemoteStream } =
+      await remoteWatcher.wait_for('quicstream');
+  localQuicTransport.stop();
+  await remoteWatcher.wait_for('statechange');
+  assert_equals(firstRemoteStream.state, 'closed');
+  assert_equals(secondRemoteStream.state, 'closed');
+}, 'RTCQuicTransport.stop() closes all remote streams.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.finish();
+  assert_equals(localStream.state, 'closing');
+}, `finish() changes state to 'closing'.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.finish();
+  localStream.finish();
+  assert_equals(localStream.state, 'closing');
+}, `finish() twice does not change state.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.reset();
+  assert_equals(localStream.state, 'closed');
+}, `reset() changes state to 'closed'.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.finish();
+  localStream.reset();
+  assert_equals(localStream.state, 'closed');
+}, `reset() following finish() changes state to 'closed'.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.finish();
+  const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
+  const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
+  assert_equals(remoteStream.state, 'open');
+  const remoteStreamWatcher = new EventWatcher(t, remoteStream, 'statechange');
+  await remoteStreamWatcher.wait_for('statechange');
+  assert_equals(remoteStream.state, 'closing');
+}, 'createStream() followed by finish() fires a quicstream event followed by ' +
+    `a statechange event to 'closing' on the remote side.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.reset();
+  const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
+  const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
+  assert_equals(remoteStream.state, 'open');
+  const remoteStreamWatcher = new EventWatcher(t, remoteStream, 'statechange');
+  await remoteStreamWatcher.wait_for('statechange');
+  assert_equals(remoteStream.state, 'closed');
+}, 'createStream() followed by reset() fires a quicstream event followed ' +
+    `by a statechange event to 'closed' on the remote side.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  remoteQuicTransport.onquicstream = ({ stream }) => stream.reset();
+  const localStream = localQuicTransport.createStream();
+  localStream.finish();
+  const localWatcher = new EventWatcher(t, localStream, 'statechange');
+  await localWatcher.wait_for('statechange');
+  assert_equals(localStream.state, 'closed');
+}, 'finish() on a remote stream that has already finished fires a ' +
+    `statechange event to 'closed' on the remote side.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.finish();
+  localStream.reset();
+  const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
+  const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
+  const remoteStreamWatcher = new EventWatcher(t, remoteStream, 'statechange');
+  await remoteStreamWatcher.wait_for('statechange');
+  assert_equals(remoteStream.state, 'closing');
+  await remoteStreamWatcher.wait_for('statechange');
+  assert_equals(remoteStream.state, 'closed');
+}, 'finish() then reset() fires two statechange events on the remote side.');
 
 </script>
--- a/testing/web-platform/tests/webrtc/RTCQuicTransport-helper.js
+++ b/testing/web-platform/tests/webrtc/RTCQuicTransport-helper.js
@@ -74,9 +74,8 @@ async function makeTwoConnectedQuicTrans
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeAndStartTwoQuicTransports(t);
   await Promise.all([
     waitForConnected(localQuicTransport),
     waitForConnected(remoteQuicTransport),
   ]);
   return [ localQuicTransport, remoteQuicTransport ];
 }
-
--- a/testing/web-platform/tests/webrtc/RTCQuicTransport.https.html
+++ b/testing/web-platform/tests/webrtc/RTCQuicTransport.https.html
@@ -12,16 +12,17 @@
 // 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:
+//   generateCertificate
 //   makeQuicTransport
 //   makeStandaloneQuicTransport
 //   makeAndStartTwoQuicTransports
 //   makeTwoConnectedQuicTransports
 
 promise_test(async t => {
   const certificate = await generateCertificate();
   const iceTransport = makeIceTransport(t);