Reapply "Use typed promises/resolvers for ReadableStream and related classes"

This converts IDL-exposed promises in ReadableStream,
ReadableStreamBYOBReader, ReadableStreamDefaultReader, and
ReadableStreamGenericReader to use typed ScriptPromiseResolver
instead of StreamPromiseResolver and to return typed
ScriptPromises.

Bug: 329702363
Change-Id: I6dad0ce6902c2dd5411185800bdd5a6dd8585df8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5410703
Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Reviewed-by: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1281906}
diff --git a/long-animation-frame/tentative/loaf-stream-source-location.html b/long-animation-frame/tentative/loaf-stream-source-location.html
index 0fd3085..5776ff5 100644
--- a/long-animation-frame/tentative/loaf-stream-source-location.html
+++ b/long-animation-frame/tentative/loaf-stream-source-location.html
@@ -17,7 +17,8 @@
     const scriptElement = document.createElement("script");
     scriptElement.src = scriptLocation;
     document.body.appendChild(scriptElement);
-  }, script => script.invoker === "StreamPromise.resolve.then", t);
+  }, script => {
+     return script.invoker === "Promise.resolve" }, t);
 
   assert_true(script.sourceURL.includes("stream-promise-generates-loaf.js"));
 }, "Source location should be extracted for stream promises");
diff --git a/long-animation-frame/tentative/loaf-stream.html b/long-animation-frame/tentative/loaf-stream.html
index e35bc2f..424f2cd 100644
--- a/long-animation-frame/tentative/loaf-stream.html
+++ b/long-animation-frame/tentative/loaf-stream.html
@@ -34,6 +34,6 @@
     });
     response.body.pipeTo(writable);
     await readable.getReader().read();
-}, "resolve", "StreamPromise.resolve");
+}, "resolve", "Promise.resolve");
 </script>
 </body>
diff --git a/streams/piping/detached-context-crash.html b/streams/piping/detached-context-crash.html
new file mode 100644
index 0000000..56271f1
--- /dev/null
+++ b/streams/piping/detached-context-crash.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<body>
+<script>
+window.onload = () => {
+  const i = document.createElement("iframe");
+  i.src = "about:blank";
+  document.body.appendChild(i);
+
+  const rs = new i.contentWindow.ReadableStream({
+    start(controller) { controller.error(); }
+  });
+  const ws = new i.contentWindow.WritableStream();
+
+  i.remove();
+
+  // pipeTo() should not crash with a ReadableStream or WritableStream from
+  // a detached iframe.
+  rs.pipeTo(ws);
+};
+</script>
+</body>