Update ReadableStreamDefaultReader implementation

This change includes updating the ReadableStreamDefaultReader
implementation to match the Streams spec. This means properly
implementing read requests so that they are not just
StreamPromiseResolvers, and have separate chunk, close, and error steps
based on where the read request is used. This CL also uses
ReadableStreamReadResult to match the spec, and finally removes the use
of `for_author_code_` which is no longer used in the standard. These
changes in turn also fix the teeing behavior.

Bug: 1227496
Change-Id: Id43ece0bef5fb5a7588e8adf64b5a4e398d5163e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3763542
Commit-Queue: Nidhi Jaju <nidhijaju@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1122821}
diff --git a/streams/transform-streams/invalid-realm.window.js b/streams/transform-streams/invalid-realm.window.js
new file mode 100644
index 0000000..57cdfd9
--- /dev/null
+++ b/streams/transform-streams/invalid-realm.window.js
@@ -0,0 +1,17 @@
+// TransformStream should still work even if the realm is detached.
+
+// Adds an iframe to the document and returns it.
+function addIframe() {
+  const iframe = document.createElement('iframe');
+  document.body.appendChild(iframe);
+  return iframe;
+}
+
+promise_test(async t => {
+  const iframe = addIframe();
+  const stream = new iframe.contentWindow.TransformStream();
+  const readPromise = stream.readable.getReader().read();
+  const writer = stream.writable.getWriter();
+  iframe.remove();
+  return Promise.all([writer.write('A'), readPromise]);
+}, 'TransformStream: write in detached realm should succeed');