summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Memory-drainAllocationsLog-15.js
blob: 471e8ce39bf68bed0904a92d2492399d77cb7bb5 (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
25
26
27
28
29
30
31
32
33
// Test drainAllocationsLog() and [[Class]] names.
if (!('Promise' in this))
    quit(0);

const root = newGlobal();
const dbg = new Debugger();
const wrappedRoot = dbg.addDebuggee(root)

root.eval(
  `
  this.tests = [
    { expected: "Object",    test: () => new Object    },
    { expected: "Array",     test: () => []            },
    { expected: "Date",      test: () => new Date      },
    { expected: "RegExp",    test: () => /problems/    },
    { expected: "Int8Array", test: () => new Int8Array },
    { expected: "Promise",   test: () => new Promise(function (){})},
  ];
  `
);


for (let { expected, test } of root.tests) {
  print(expected);

  dbg.memory.trackingAllocationSites = true;
  test();
  let allocs = dbg.memory.drainAllocationsLog();
  dbg.memory.trackingAllocationSites = false;

  assertEq(allocs.some(a => a.class === expected), true);
}