<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>
<script src="../resources/audiocontext-leak-test.js"></script>
<script>
description("Makes sure that the OfflineAudioContext objects are not leaking when suspended.");
jsTestIsAsync = true;

const instancesToCreate = 100;
let suspendPromises = [];
for (let i = 0; i < instancesToCreate; i++) {
    let context = new OfflineAudioContext(2, 44100, 44100);
    trackContextForLeaks(context);
    suspendPromises.push(context.suspend(0.5));
    context.startRendering();
}

Promise.all(suspendPromises).then((values) => {
    gcAndCheckForContextLeaks();
});
</script>
</body>
</html>
