Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /streams/writable-streams/garbage-collection.any.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.serviceworker.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.shadowrealm-in-dedicatedworker.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.shadowrealm-in-shadowrealm.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.shadowrealm-in-sharedworker.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.shadowrealm-in-window.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.any.worker.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.https.any.shadowrealm-in-audioworklet.html - WPT Dashboard Interop Dashboard
- /streams/writable-streams/garbage-collection.https.any.shadowrealm-in-serviceworker.html - WPT Dashboard Interop Dashboard
// META: global=window,worker,shadowrealm
// META: script=/common/gc.js
'use strict';
promise_test(async () => {
let written = false;
const promise = (() => {
const rs = new WritableStream({
write() {
written = true;
}
});
const writer = rs.getWriter();
return writer.write('something');
})();
await garbageCollect();
await promise;
assert_true(written);
}, 'A WritableStream and its writer should not be garbage collected while there is a write promise pending');