summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/gc/bug-1602741.js
blob: 5f1cc7eca8f6b5c444dfbd26099b6a484ee238a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Test that drainJobQueue() drains all jobs, including those queued
// by FinalizationRegistry callbacks.

let finalizeRan = false;
let promiseRan = false;

let fr = new FinalizationRegistry(() => {
  finalizeRan = true;
  Promise.resolve().then(() => {
    promiseRan = true;
  });
});

fr.register({}, {});

gc();

assertEq(finalizeRan, false);
assertEq(promiseRan, false);

drainJobQueue();

assertEq(finalizeRan, true);
assertEq(promiseRan, true);