summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/streams/transferable/gc-crash.html
blob: 0d331e6be08059d0ef911385e21195090114a178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html class="test-wait">
<script src="/common/gc.js"></script>
<script type="module">
  const b = new ReadableStream({
    start(c) {
      c.enqueue({}) // the value we will transfer
    },
  })
  const transferred = structuredClone(b, { transfer: [b] })
  // Here we request a read, triggering a message transfer
  transferred.getReader().read()
  // And immediately trigger GC without waiting for the read,
  // causing the actual transfer to be done after GC
  await garbageCollect()
  document.documentElement.classList.remove("test-wait")
</script>