Debian Codegraph @

testing/web-platform/tests/streams/writable-streams/crashtests/garbage-collection.any.js

raw
1 // META: global=window,worker
2 // META: script=/common/gc.js
3 'use strict';
4
5 // See https://crbug.com/390646657 for details.
6 promise_test(async () => {
7 const written = new WritableStream({
8 write(chunk) {
9 return new Promise(resolve => {});
10 }
11 }).getWriter().write('just nod if you can hear me');
12 for (let i = 0; i < 5; ++i)
13 await garbageCollect();
14 }, 'Garbage-collecting a stream writer with a pending write should not crash');
15
16 promise_test(async () => {
17 const closed = new WritableStream({
18 write(chunk) { }
19 }).getWriter().closed;
20 for (let i = 0; i < 5; ++i)
21 await garbageCollect();
22 }, 'Garbage-collecting a stream writer should not crash with closed promise is retained');
23
24 promise_test(async () => {
25 let writer = new WritableStream({
26 write(chunk) { return new Promise(resolve => {}); },
27 close() { return new Promise(resolve => {}); }
28 }).getWriter();
29 writer.write('is there anyone home?');
30 writer.close();
31 writer = null;
32 for (let i = 0; i < 5; ++i)
33 await garbageCollect();
34 }, 'Garbage-collecting a stream writer should not crash with close promise pending');
35
36 promise_test(async () => {
37 const ready = new WritableStream({
38 write(chunk) { }
39 }, {highWaterMark: 0}).getWriter().ready;
40 for (let i = 0; i < 5; ++i)
41 await garbageCollect();
42 }, 'Garbage-collecting a stream writer should not crash when backpressure is being applied');
43