1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-11 10:07:54 -05:00
denoland-deno/tests/testdata/test/load_unload.ts

26 lines
489 B
TypeScript
Raw Permalink Normal View History

let interval: number | null = null;
addEventListener("load", () => {
if (interval) {
throw new Error("Interval is already set");
}
console.log("load");
interval = setInterval(() => {}, 0);
});
addEventListener("unload", () => {
if (!interval) {
throw new Error("Interval was not set");
}
console.log("unload");
clearInterval(interval);
});
Deno.test("test", () => {
console.log("test");
if (!interval) {
throw new Error("Interval was not set");
}
});