4 Bug 1132764 - Test controlling the maximum allocations log length over the RDP.
8 <title>Memory monitoring actor test
</title>
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css">
14 <script src=
"memory-helpers.js" type=
"application/javascript"></script>
18 window
.onload = function() {
19 SimpleTest
.waitForExplicitFinish();
22 const { memory
, target
} = await
startServerAndGetSelectedTabMemory();
23 await memory
.attach();
27 let intervalId
= null;
31 function startAllocating() {
32 intervalId
= setInterval(() => {
33 for (let i
= 100000; --i
;) {
38 function stopAllocating() {
39 clearInterval(intervalId
);
42 memory
.on("allocations", onAlloc
);
44 await memory
.startRecordingAllocations({
45 drainAllocationsTimeout
: 10,
48 await
waitUntil(() => eventsFired
> 5);
50 "Some allocation events fired without allocating much via auto drain");
51 await memory
.stopRecordingAllocations();
53 // Set a really high auto drain timer so we can test if
56 const startTime
= performance
.now();
57 const drainTimer
= 1000000;
58 await memory
.startRecordingAllocations({
59 drainAllocationsTimeout
: drainTimer
,
63 await
waitUntil(() => {
65 return eventsFired
> 1;
68 ok(performance
.now() - drainTimer
< startTime
,
69 "Allocation events fired on GC before timer");
70 await memory
.stopRecordingAllocations();
72 memory
.off("allocations", onAlloc
);
73 await memory
.detach();
74 destroyServerAndFinish(target
);