diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-10-02 17:32:51 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-02 11:32:51 -0400 |
commit | c920c5f62aba7eee0f6fa70f68f701e204ac1a9c (patch) | |
tree | 3ab590972146e11d75f1ddd296ab1a6aead58906 /cli/tests/034_onload/main.ts | |
parent | d32f39f2ec271c7517bbd5113827dc43a7e40641 (diff) |
feat: window.onunload (#3023)
Diffstat (limited to 'cli/tests/034_onload/main.ts')
-rw-r--r-- | cli/tests/034_onload/main.ts | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/cli/tests/034_onload/main.ts b/cli/tests/034_onload/main.ts index 68851950a..c3c6bdcc9 100644 --- a/cli/tests/034_onload/main.ts +++ b/cli/tests/034_onload/main.ts @@ -1,14 +1,23 @@ +import { assert } from "../../../js/deps/https/deno.land/std/testing/asserts.ts"; import "./imported.ts"; -window.addEventListener( - "load", - (e: Event): void => { - console.log(`got ${e.type} event in event handler (main)`); - } -); +const eventHandler = (e: Event): void => { + assert(!e.cancelable); + console.log(`got ${e.type} event in event handler (main)`); +}; + +window.addEventListener("load", eventHandler); + +window.addEventListener("unload", eventHandler); window.onload = (e: Event): void => { + assert(!e.cancelable); console.log(`got ${e.type} event in onload function`); }; +window.onunload = (e: Event): void => { + assert(!e.cancelable); + console.log(`got ${e.type} event in onunload function`); +}; + console.log("log from main"); |