Add test for emulator getting garbage-collected

This commit is contained in:
Fabian 2022-07-29 00:18:07 +09:00
parent d28c77faa2
commit c4597d78aa

33
tests/manual/gc.html Normal file
View file

@ -0,0 +1,33 @@
<!doctype html>
<title>Test that emulator is GCed properly</title>
<script src="../../build/libv86.js"></script>
<script>
"use strict";
window.onload = function()
{
var emulator = new V86Starter({
wasm_path: "../../build/v86.wasm",
memory_size: 32 * 1024 * 1024,
vga_memory_size: 2 * 1024 * 1024,
screen_container: document.getElementById("screen_container"),
bios: { url: "../../bios/seabios.bin" },
vga_bios: { url: "../../bios/vgabios.bin" },
cdrom: { url: "../../images/linux.iso" },
autostart: true,
});
setTimeout(() => {
emulator.stop();
emulator.destroy();
console.log("Emulator freed. Check using devtools (in chromium: Memory -> Heap Snapshot -> click collect garbage -> take snapshot).");
}, 3 * 1000);
}
</script>
<!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
<div id="screen_container">
<div style="white-space: pre; font: 14px monospace; line-height: 14px"></div>
<canvas style="display: none"></canvas>
</div>