Bug 1514099 [wpt PR 14510] - Update for RTCQuicStream.write() function., a=testonly
authorSeth Hampson <shampson@chromium.org>
Wed, 19 Dec 2018 12:09:22 +0000
changeset 515034 990811660670a3569923e20aee0c4a4ee541ae4d
parent 515033 5395db370569cbf4988ce37b4f3016d5cfbcb2b9
child 515035 a2b2c1fa37b33ff14f5cfa3b548bc2dc105b73f6
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1514099, 14510, 874296, 1376720, 616941
milestone66.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 1514099 [wpt PR 14510] - Update for RTCQuicStream.write() function., a=testonly Automatic update from web-platform-tests Update for RTCQuicStream.write() function. Combines functionality of finish() into write() by adding a new QuicStreamWriteParameters input parameter that includes a finish boolean. This is consistent with the latest spec draft and also adds symmetry between readInto() and write(). Bug: 874296 Change-Id: I0def0ca25587ebf00a4b179ce8e9e7a124c818f6 Reviewed-on: https://chromium-review.googlesource.com/c/1376720 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@{#616941} -- wpt-commits: a3efcf10006556ecb6169610324f650a5522650d wpt-pr: 14510
testing/web-platform/tests/webrtc-quic/RTCQuicStream-helper.js
testing/web-platform/tests/webrtc-quic/RTCQuicStream.https.html
--- a/testing/web-platform/tests/webrtc-quic/RTCQuicStream-helper.js
+++ b/testing/web-platform/tests/webrtc-quic/RTCQuicStream-helper.js
@@ -18,82 +18,81 @@ function closed_stream_test(test_func, d
     assert_equals(localStream.state, 'closed');
     return test_func(t, localStream);
   }, 'Stream closed by local reset(): ' + description);
 
   promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
         await makeTwoConnectedQuicTransports(t);
     const localStream = localQuicTransport.createStream();
-    localStream.write(new Uint8Array(1));
+    localStream.write({ data: new Uint8Array(1) });
     const remoteWatcher =
         new EventWatcher(t, remoteQuicTransport, 'quicstream');
     const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
     localStream.reset();
     const remoteStreamWatcher =
         new EventWatcher(t, remoteStream, 'statechange');
     await remoteStreamWatcher.wait_for('statechange');
     assert_equals(remoteStream.state, 'closed');
     return test_func(t, remoteStream);
   }, 'Stream closed by remote reset(): ' + description);
 
   promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
         await makeTwoConnectedQuicTransports(t);
     const localStream = localQuicTransport.createStream();
-    localStream.finish();
+    localStream.write({ finish: true });
     const remoteWatcher =
         new EventWatcher(t, remoteQuicTransport, 'quicstream');
     const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
-    remoteStream.finish();
+    remoteStream.write({ finish: true });
     await localStream.waitForReadable(localStream.maxReadBufferedAmount);
     assert_object_equals(
         localStream.readInto(new Uint8Array(10)),
         { amount: 0, finished: true });
     assert_equals(localStream.state, 'closed');
     return test_func(t, localStream);
-  }, 'Stream closed by finish(), followed by reading remote finish: ' +
+  }, 'Stream closed by writing a finish, followed by reading remote finish: ' +
       description);
 
   promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
         await makeTwoConnectedQuicTransports(t);
     const localStream = localQuicTransport.createStream();
-    localStream.write(new Uint8Array(1));
+    localStream.write({ finish: true });
     const remoteWatcher =
         new EventWatcher(t, remoteQuicTransport, 'quicstream');
     const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
-    remoteStream.finish();
-    await localStream.waitForReadable(localStream.maxReadBufferedAmount);
+    await remoteStream.waitForReadable(10);
     assert_object_equals(
-        localStream.readInto(new Uint8Array(10)),
+        remoteStream.readInto(new Uint8Array(10)),
         { amount: 0, finished: true });
-    localStream.finish();
-    assert_equals(localStream.state, 'closed');
-    return test_func(t, localStream);
-  }, 'Stream closed by by reading remote finish, followed by finish(): ' +
-      description);
+    remoteStream.write({ finish: true });
+    assert_equals(remoteStream.state, 'closed');
+    return test_func(t, remoteStream);
+  }, 'Stream closed by by reading remote finish, followed by writing a ' +
+      'finish: ' + description);
 
   promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
         await makeTwoConnectedQuicTransports(t);
     const localStream = localQuicTransport.createStream();
     localQuicTransport.stop();
     assert_equals(localStream.state, 'closed');
     return test_func(t, localStream);
   }, 'Stream closed by local RTCQuicTransport stop(): ' + description);
 
   promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
         await makeTwoConnectedQuicTransports(t);
     const localStream = localQuicTransport.createStream();
-    localStream.write(new Uint8Array(1));
+    localStream.write({ data: new Uint8Array(1) });
     const remoteWatcher =
         new EventWatcher(t, remoteQuicTransport,
             [ 'quicstream', 'statechange' ]);
     const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
     localQuicTransport.stop();
     await remoteWatcher.wait_for('statechange');
-    assert_equals(localStream.state, 'closed');
-    return test_func(t, localStream);
+    assert_equals(remoteStream.state, 'closed');
+    return test_func(t, remoteStream);
   }, 'Stream closed by remote RTCQuicTransport stop(): ' + description);
 }
 
--- a/testing/web-platform/tests/webrtc-quic/RTCQuicStream.https.html
+++ b/testing/web-platform/tests/webrtc-quic/RTCQuicStream.https.html
@@ -50,63 +50,73 @@ promise_test(async t => {
   quicTransport.stop();
   assert_equals(firstQuicStream.state, 'closed');
   assert_equals(secondQuicStream.state, 'closed');
 }, 'RTCQuicTransport.stop() closes all local streams.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
-  localQuicTransport.createStream().finish();
-  localQuicTransport.createStream().finish();
+  localQuicTransport.createStream().write({ data: new Uint8Array([42]) });
+  localQuicTransport.createStream().write({ data: new Uint8Array([42]) });
   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();
+  localStream.write({ finish: true });
   assert_equals(localStream.state, 'closing');
-}, `finish() changes state to 'closing'.`);
+}, `write() with a finish changes state to 'closing'.`);
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
-  localStream.finish();
+  localStream.write({ data: new Uint8Array(), finish: true });
   assert_equals(localStream.state, 'closing');
-}, `finish() twice does not change state.`);
+}, 'write() with a finish and an empty array changes state ' +
+    `to 'closing'.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.write({ finish: true });
+  assert_throws('InvalidStateError', () => {
+    localStream.write({ finish: true });
+  });
+}, `write() with finish twice throws InvalidStateError.`);
 
 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.write({ finish: true });
   localStream.reset();
   assert_equals(localStream.state, 'closed');
-}, `reset() following finish() changes state to 'closed'.`);
+}, `reset() following write with finish changes state to 'closed'.`);
 
 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');
@@ -116,67 +126,67 @@ promise_test(async t => {
   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);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   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 remoteStream.waitForReadable(remoteStream.maxReadBufferedAmount);
   assert_object_equals(
       remoteStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true } );
   assert_equals(remoteStream.state, 'closing');
-}, 'waitForReadable() resolves with remote finish');
+}, 'waitForReadable() promise resolves with remote finish');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(remoteStream.maxReadBufferedAmount);
   assert_object_equals(
       remoteStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true } );
   assert_equals(remoteStream.state, 'closing');
-  remoteStream.finish()
+  remoteStream.write({ finish: true });
   assert_equals(remoteStream.state, 'closed');
-}, 'finish() on a stream that has already read out finish changes ' +
-    `state to 'closed'.`);
+}, 'write() with a finish on a stream that has already read out finish ' +
+    `changes state to 'closed'.`);
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
-  remoteStream.finish();
+  remoteStream.write({ finish: true });
   assert_equals(localStream.state, 'closing');
   await localStream.waitForReadable(localStream.maxReadBufferedAmount);
   assert_object_equals(
       localStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true } );
   assert_equals(localStream.state, 'closed');
-}, 'Reading out finish on stream that has already called finish()  ' +
-    `state to 'closed'.`);
+}, 'Reading out finish on stream that has already called write() with a ' +
+    `finish  state to 'closed'.`);
 
 promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(remoteStream.maxReadBufferedAmount);
   assert_object_equals(
       remoteStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true } );
   assert_equals(remoteStream.state, 'closing');
   localStream.reset();
@@ -185,172 +195,191 @@ promise_test(async t => {
   assert_equals(remoteStream.state, 'closed');
 }, 'Reading out finish then a getting a remote reset fires a statechange event ' +
     `to 'closed'.`);
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
     await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(0));
-  assert_equals(localStream.writeBufferedAmount, 0);
-}, 'write() with an empty array does nothing.');
+  assert_throws('NotSupportedError', () =>
+      localStream.write({ data: new Uint8Array() }));
+}, 'write() without finish and an empty array throws NotSupportedError.');
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+    await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  assert_throws('NotSupportedError', () =>
+      localStream.write({}));
+}, 'write() without finish and no data throws NotSupportedError.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
     await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array([65]));
+  localStream.write({ data: new Uint8Array([65]) });
   assert_equals(localStream.writeBufferedAmount, 1);
-  localStream.write(new Uint8Array([66, 67]));
+  localStream.write({ data: new Uint8Array([66, 67]) });
   assert_equals(localStream.writeBufferedAmount, 3);
-  localStream.write(new Uint8Array([68, 69, 70]));
+  localStream.write({ data: new Uint8Array([68, 69, 70]) });
   assert_equals(localStream.writeBufferedAmount, 6);
 }, 'write() adds to writeBufferedAmount each call.');
 
+
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(localStream.maxWriteBufferedAmount));
+  localStream.write({ data: new Uint8Array([42, 43]), finish: true });
+  assert_equals(localStream.writeBufferedAmount, 2);
+}, `write() data with a finish adds to writeBufferedAmount.`);
+
+promise_test(async t => {
+  const [ localQuicTransport, remoteQuicTransport ] =
+      await makeTwoConnectedQuicTransports(t);
+  const localStream = localQuicTransport.createStream();
+  localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount)
+  });
   assert_equals(localStream.writeBufferedAmount,
       localStream.maxWriteBufferedAmount);
 }, 'write() can write exactly maxWriteBufferedAmount.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  assert_throws('OperationError',
-      () =>
-          localStream.write(
-              new Uint8Array(localStream.maxWriteBufferedAmount + 1)));
+  assert_throws('OperationError', () => localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount + 1)
+  }));
   assert_equals(localStream.writeBufferedAmount, 0);
 }, 'write() throws if data longer than maxWriteBufferedAmount.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(10));
-  assert_throws('OperationError',
-      () =>
-          localStream.write(
-              new Uint8Array(localStream.maxWriteBufferedAmount)));
+  localStream.write(
+      { data: new Uint8Array(10)});
+  assert_throws('OperationError', () => localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount)
+  }));
   assert_equals(localStream.writeBufferedAmount, 10);
 }, 'write() throws if total write buffered amount would be greater than ' +
     'maxWriteBufferedAmount.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(10));
+  localStream.write({ data: new Uint8Array(10) });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   await remoteWatcher.wait_for('quicstream');
 }, 'write() causes quicstream event to fire on the remote transport.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });;
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   await remoteWatcher.wait_for('quicstream');
-}, 'finish() causes quicstream event to fire on the remote transport.');
+}, 'write() with a finish causes quicstream event to fire on the ' +
+    'remote transport.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   assert_throws('InvalidStateError',
-      () => localStream.write(new Uint8Array()));
-}, 'write() throws InvalidStateError if finish() has been called.');
+      () => localStream.write({ data: new Uint8Array([65]) }));
+}, 'write() throws InvalidStateError if write() with finish has been called.');
 
 closed_stream_test(async (t, stream) => {
-  assert_throws('InvalidStateError', () => stream.write(new Uint8Array()));
+  assert_throws('InvalidStateError',
+  () => stream.write({ data: new Uint8Array([65]) }));
 }, 'write() throws InvalidStateError.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(generateData(10));
+  localStream.write({ data: generateData(10) });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream : remoteStream} = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(10);
   assert_equals(10, remoteStream.readBufferedAmount);
   remoteStream.reset();
   assert_equals(0, remoteStream.readBufferedAmount);
 }, 'readBufferedAmount set to 0 after local reset().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(generateData(10));
+  localStream.write({ data: generateData(10) });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream : remoteStream} = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(10);
   assert_equals(10, remoteStream.readBufferedAmount);
   localStream.reset();
   const remoteStreamWatcher =
         new EventWatcher(t, remoteStream, 'statechange');
   await remoteStreamWatcher.wait_for('statechange');
   assert_equals(remoteStream.state, 'closed');
   assert_equals(0, remoteStream.readBufferedAmount);
 }, 'readBufferedAmount set to 0 after remote reset().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(10));
+  localStream.write({ data: new Uint8Array(10) });
   localStream.reset();
   assert_equals(localStream.writeBufferedAmount, 0);
 }, 'writeBufferedAmount set to 0 after local reset().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(1));
+  localStream.write({ finish: true });
   const remoteWatcher =
       new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
-  remoteStream.finish();
-  await localStream.waitForReadable(localStream.maxReadBufferedAmount);
+  await remoteStream.waitForReadable(10);
   assert_object_equals(
-      localStream.readInto(new Uint8Array(10)),
+      remoteStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true });
-  localStream.write(new Uint8Array(10));
-  assert_equals(localStream.writeBufferedAmount, 10);
-  localStream.finish();
-  assert_equals(localStream.writeBufferedAmount, 0);
+  remoteStream.write({ data: new Uint8Array(10) });
+  assert_equals(remoteStream.writeBufferedAmount, 10);
+  remoteStream.write({ finish: true });
+  assert_equals(remoteStream.writeBufferedAmount, 0);
 }, 'writeBufferedAmount set to 0 after reading remote finish, followed ' +
-    'by finish().');
+    'by write() with finish.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(10));
+  localStream.write({ data: new Uint8Array(10) });
   localQuicTransport.stop();
   assert_equals(localStream.writeBufferedAmount, 0);
 }, 'writeBufferedAmount set to 0 after local RTCQuicTransport stop().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(10));
-  localStream.finish();
+  localStream.write({ data: new Uint8Array(10) });
+  localStream.write({ finish: true });
   assert_equals(localStream.writeBufferedAmount, 10);
-}, 'writeBufferedAmount maintained after finish() has been called.');
+}, 'writeBufferedAmount maintained after write() with finish has been called.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
   await localStream.waitForWriteBufferedAmountBelow(0);
 }, 'waitForWriteBufferedAmountBelow(0) resolves immediately.');
 
@@ -362,59 +391,67 @@ promise_test(async t => {
       localStream.maxWriteBufferedAmount);
 }, 'waitForWriteBufferedAmountBelow(maxWriteBufferedAmount) resolves ' +
     'immediately.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(localStream.maxWriteBufferedAmount));
+  localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount)
+  });
   const promise1 = localStream.waitForWriteBufferedAmountBelow(0);
   const promise2 = localStream.waitForWriteBufferedAmountBelow(0);
-  localStream.finish();
+  localStream.write({ finish: true });
   await Promise.all([
       promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);
 }, 'Pending waitForWriteBufferedAmountBelow() promises rejected after ' +
-    'finish().');
+    'write() with finish.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(localStream.maxWriteBufferedAmount));
-  localStream.finish();
+  localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount)
+  });
+  localStream.write({ finish: true });
   const promise1 = localStream.waitForWriteBufferedAmountBelow(0);
   const promise2 = localStream.waitForWriteBufferedAmountBelow(0);
   await Promise.all([
       promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);
 }, 'waitForWriteBufferedAmountBelow() promises immediately rejected after ' +
-    'finish().');
+    'wrote finish.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(localStream.maxWriteBufferedAmount));
+  localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount)
+  });
   const promise1 = localStream.waitForWriteBufferedAmountBelow(0);
   const promise2 = localStream.waitForWriteBufferedAmountBelow(0);
   localStream.reset();
   await Promise.all([
       promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);
 }, 'Pending waitForWriteBufferedAmountBelow() promises rejected after ' +
     'reset().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(localStream.maxWriteBufferedAmount));
+  localStream.write({
+    data: new Uint8Array(localStream.maxWriteBufferedAmount)
+  });
   const promise1 = localStream.waitForWriteBufferedAmountBelow(0);
   const promise2 = localStream.waitForWriteBufferedAmountBelow(0);
   localQuicTransport.stop();
   await Promise.all([
       promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);
 }, 'Pending waitForWriteBufferedAmountBelow() promises rejected after ' +
     'RTCQuicTransport stop().');
@@ -436,17 +473,17 @@ promise_test(async t => {
 closed_stream_test(async (t, stream) => {
   assert_throws('InvalidStateError', () => stream.readInto(new Uint8Array(1)));
 }, 'readInto() throws InvalidStateError.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array([ 65 ]));
+  localStream.write({ data: new Uint8Array([ 65 ]) });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(1);
   assert_equals(remoteStream.readBufferedAmount, 1);
   const readBuffer = new Uint8Array(3);
   assert_object_equals(
       remoteStream.readInto(readBuffer),
       { amount: 1, finished: false } );
@@ -465,28 +502,27 @@ function generateData(amount) {
 
 // Writes |amount| of bytes to the given RTCQuicStream in maxWriteBufferedAmount
 // chunks.
 async function writeGeneratedData(stream, amount) {
   const data = generateData(Math.min(stream.maxWriteBufferedAmount, amount));
   while (amount > 0) {
     const chunkSize = Math.min(stream.maxWriteBufferedAmount, amount);
     await stream.waitForWriteBufferedAmountBelow(0);
-    stream.write(data.subarray(0, chunkSize));
+    stream.write({ data: data.subarray(0, chunkSize) });
     amount -= chunkSize;
   }
 }
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
   const data = generateData(10);
-  localStream.write(data);
-  localStream.finish();
+  localStream.write({ data: data, finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(data.length + 1);
   const readBuffer = new Uint8Array(5);
   assert_object_equals(
       remoteStream.readInto(readBuffer),
       { amount: 5, finished: false} );
   assert_array_equals(
@@ -514,32 +550,32 @@ promise_test(async t => {
   assert_array_equals(
       readBuffer, generateData(localStream.maxReadBufferedAmount));
 }, 'Read maxReadBufferedAmount bytes all at once.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(remoteStream.maxReadBufferedAmount);
   assert_object_equals(
       remoteStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true } );
-}, 'waitForReadable() resolves with finish().');
+}, 'waitForReadable() resolves with write() with finish.');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
   const writeData = generateData(10);
-  localStream.write(writeData);
-  localStream.finish();
+  localStream.write({ data: writeData });
+  localStream.write({ finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(11);
   assert_equals(remoteStream.readBufferedAmount, 10);
   const readBuffer = new Uint8Array(10);
   assert_object_equals(
       remoteStream.readInto(readBuffer), { amount: 10, finished: true } );
   assert_array_equals(readBuffer, writeData);
@@ -553,17 +589,17 @@ promise_test(async t => {
       localStream.waitForReadable(localStream.maxReadBufferedAmount + 1));
 }, 'waitForReadable() rejects with TypeError if amount is more than ' +
     'maxReadBufferedAmount.');
 
 promise_test(async t => {
     const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.finish();
+  localStream.write({ finish: true });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream: remoteStream } = await remoteWatcher.wait_for('quicstream');
   await remoteStream.waitForReadable(remoteStream.maxReadBufferedAmount);
   assert_object_equals(
       remoteStream.readInto(new Uint8Array(10)),
       { amount: 0, finished: true } );
 
   const promise1 = remoteStream.waitForReadable(10);
@@ -577,25 +613,25 @@ promise_test(async t => {
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
   const promise1 = localStream.waitForReadable(10);
   const promise2 = localStream.waitForReadable(10);
   localStream.reset();
   await Promise.all([
-      promise_rejects(t, 'InvalidStateError', promise1),
+promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);
 }, 'Pending waitForReadable() promises rejected after reset().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(1));
+  localStream.write({ data: new Uint8Array(1) });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream : remoteStream} = await remoteWatcher.wait_for('quicstream');
   const promise1 = remoteStream.waitForReadable(10);
   const promise2 = remoteStream.waitForReadable(10);
   localStream.reset();
   await Promise.all([
       promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);
@@ -613,17 +649,17 @@ promise_test(async t => {
       promise_rejects(t, 'InvalidStateError', promise2)]);
 }, 'Pending waitForReadable() promises rejected after RTCQuicTransport ' +
    'stop().');
 
 promise_test(async t => {
   const [ localQuicTransport, remoteQuicTransport ] =
       await makeTwoConnectedQuicTransports(t);
   const localStream = localQuicTransport.createStream();
-  localStream.write(new Uint8Array(1));
+  localStream.write({ data: new Uint8Array(1) });
   const remoteWatcher = new EventWatcher(t, remoteQuicTransport, 'quicstream');
   const { stream : remoteStream} = await remoteWatcher.wait_for('quicstream');
   const promise1 = remoteStream.waitForReadable(10);
   const promise2 = remoteStream.waitForReadable(10);
   localQuicTransport.stop();
   await Promise.all([
       promise_rejects(t, 'InvalidStateError', promise1),
       promise_rejects(t, 'InvalidStateError', promise2)]);