garbage-collection.any.js (1161B)
1 // META: global=window,worker 2 // META: script=/common/gc.js 3 'use strict'; 4 5 // See https://crbug.com/335506658 for details. 6 promise_test(async () => { 7 const closed = new ReadableStream({ 8 pull(controller) { 9 controller.enqueue('is there anybody in there?'); 10 } 11 }).getReader().closed; 12 // 3 GCs are actually required to trigger the bug at time of writing. 13 for (let i = 0; i < 5; ++i) 14 await garbageCollect(); 15 }, 'Garbage-collecting a stream along with its reader should not crash'); 16 17 promise_test(async () => { 18 let reader = new ReadableStream({ 19 pull() { } 20 }).getReader(); 21 const promise = reader.read(); 22 reader = null; 23 for (let i = 0; i < 5; ++i) 24 await garbageCollect(); 25 }, 'Garbage-collecting a stream with a pending read should not crash'); 26 27 promise_test(async () => { 28 let reader = new ReadableStream({ 29 type: "bytes", 30 pull() { return new Promise(resolve => {}); } 31 }).getReader({mode: "byob"}); 32 const promise = reader.read(new Uint8Array(42)); 33 reader = null; 34 for (let i = 0; i < 5; ++i) 35 await garbageCollect(); 36 }, 'Garbage-collecting a stream with a pending BYOB read should not crash');