gecko-dev/testing/web-platform/tests/fetch/api/basic/gc.any.js
Kagami Sascha Rosylight b9af86bfb4 Bug 1941210 - Strongly grab FetchStreamReader while waiting for writing r=smaug
Nothing strongly grabs ReadableStream nor FetchStreamReader while waiting for nsIAsyncOutputStream to respond. mAsyncWaitReader should now strongly grab the reader until the output stream responds.

Differential Revision: https://phabricator.services.mozilla.com/D234031
2025-01-14 19:24:05 +00:00

19 lines
530 B
JavaScript

// META: global=window,worker
// META: script=/common/gc.js
promise_test(async () => {
let i = 0;
const repeat = 5;
const buffer = await new Response(new ReadableStream({
pull(c) {
if (i >= repeat) {
c.close();
return;
}
++i;
c.enqueue(new Uint8Array([0]))
garbageCollect();
}
})).arrayBuffer();
assert_equals(buffer.byteLength, repeat, `The buffer should be ${repeat}-byte long`);
}, "GC/CC should not abruptly close the stream while being consumed by Response");