blob: 4bf3d6452c2e7c398e07ed5700266567cc8116b1 [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("Heap.gc");
suite.addTestCase({
name: "TriggerGCShouldCreateGCEvent",
description: "Calling Heap.gc should trigger Heap.garbageCollected event if enabled.",
test(resolve, reject) {
HeapAgent.gc();
let resolving = false;
WI.heapManager.addEventListener(WI.HeapManager.Event.GarbageCollected, (event) => {
// Due to the asynchronous nature of Heap.garbageCollected events, we may see
// non-Full GC events before we see the Full collection triggered by HeapAgent.gc.
if (!resolving && event.data.collection.type === WI.GarbageCollection.Type.Full) {
InspectorTest.expectThat(event.data.collection instanceof WI.GarbageCollection, "Event should have GarbageCollection data.");
InspectorTest.expectThat(event.data.collection.type === WI.GarbageCollection.Type.Full, "GarbageCollection type should be Full.");
resolving = true;
resolve();
}
});
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Test for the Heap.gc command.</p>
</body>
</html>