Skip to content

Commit

Permalink
Use typed promises/resolvers for ReadableStream and related classes, …
Browse files Browse the repository at this point in the history
…attempt #3

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: I8ad1af1a7c9c909d711881ce7621c6c9fac58931
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5429731
Reviewed-by: Adam Rice <ricea@chromium.org>
Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1289397}
  • Loading branch information
natechapin authored and chromium-wpt-export-bot committed Apr 18, 2024
1 parent 2f45407 commit 26d9744
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
Expand Up @@ -17,7 +17,8 @@ <h1>Long Animation Frame: source location extraction for streams</h1>
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");
Expand Down
2 changes: 1 addition & 1 deletion long-animation-frame/tentative/loaf-stream.html
Expand Up @@ -34,6 +34,6 @@ <h1>Long Animation Frame: stream promise resolvers</h1>
});
response.body.pipeTo(writable);
await readable.getReader().read();
}, "resolve", "StreamPromise.resolve");
}, "resolve", "Promise.resolve");
</script>
</body>
21 changes: 21 additions & 0 deletions 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>
13 changes: 13 additions & 0 deletions streams/readable-streams/tee-detached-context-crash.html
@@ -0,0 +1,13 @@
<!doctype html>
<body>
<script>
const i = document.createElement("iframe");
document.body.appendChild(i);

const rs = new i.contentWindow.ReadableStream();
i.remove();

// tee() on a ReadableStream from a detached iframe should not crash.
rs.tee();
</script>
</body>

0 comments on commit 26d9744

Please sign in to comment.