diff options
Diffstat (limited to 'tests/testdata/run/onload')
| -rw-r--r-- | tests/testdata/run/onload/imported.ts | 7 | ||||
| -rw-r--r-- | tests/testdata/run/onload/main.ts | 18 | ||||
| -rw-r--r-- | tests/testdata/run/onload/nest_imported.ts | 7 |
3 files changed, 15 insertions, 17 deletions
diff --git a/tests/testdata/run/onload/imported.ts b/tests/testdata/run/onload/imported.ts index 77d3da998..643e2fc78 100644 --- a/tests/testdata/run/onload/imported.ts +++ b/tests/testdata/run/onload/imported.ts @@ -1,4 +1,3 @@ -// deno-lint-ignore-file no-window-prefix import { assert } from "@std/assert"; import "./nest_imported.ts"; @@ -7,7 +6,7 @@ const handler = (e: Event) => { console.log(`got ${e.type} event in event handler (imported)`); }; -window.addEventListener("load", handler); -window.addEventListener("beforeunload", handler); -window.addEventListener("unload", handler); +globalThis.addEventListener("load", handler); +globalThis.addEventListener("beforeunload", handler); +globalThis.addEventListener("unload", handler); console.log("log from imported script"); diff --git a/tests/testdata/run/onload/main.ts b/tests/testdata/run/onload/main.ts index 69bd174fa..c4b8424fb 100644 --- a/tests/testdata/run/onload/main.ts +++ b/tests/testdata/run/onload/main.ts @@ -1,32 +1,32 @@ -// deno-lint-ignore-file no-window-prefix no-prototype-builtins +// deno-lint-ignore-file no-prototype-builtins import { assert } from "@std/assert"; import "./imported.ts"; -assert(window.hasOwnProperty("onload")); -assert(window.onload === null); +assert(globalThis.hasOwnProperty("onload")); +assert(globalThis.onload === null); const eventHandler = (e: Event) => { assert(e.type === "beforeunload" ? e.cancelable : !e.cancelable); console.log(`got ${e.type} event in event handler (main)`); }; -window.addEventListener("load", eventHandler); +globalThis.addEventListener("load", eventHandler); -window.addEventListener("beforeunload", eventHandler); +globalThis.addEventListener("beforeunload", eventHandler); -window.addEventListener("unload", eventHandler); +globalThis.addEventListener("unload", eventHandler); -window.onload = (e: Event) => { +globalThis.onload = (e: Event) => { assert(!e.cancelable); console.log(`got ${e.type} event in onload function`); }; -window.onbeforeunload = (e: BeforeUnloadEvent) => { +globalThis.onbeforeunload = (e: BeforeUnloadEvent) => { assert(e.cancelable); console.log(`got ${e.type} event in onbeforeunload function`); }; -window.onunload = (e: Event) => { +globalThis.onunload = (e: Event) => { assert(!e.cancelable); console.log(`got ${e.type} event in onunload function`); }; diff --git a/tests/testdata/run/onload/nest_imported.ts b/tests/testdata/run/onload/nest_imported.ts index dbe313b9c..f1d28e8dc 100644 --- a/tests/testdata/run/onload/nest_imported.ts +++ b/tests/testdata/run/onload/nest_imported.ts @@ -1,4 +1,3 @@ -// deno-lint-ignore-file no-window-prefix import { assert } from "@std/assert"; const handler = (e: Event) => { @@ -6,7 +5,7 @@ const handler = (e: Event) => { console.log(`got ${e.type} event in event handler (nest_imported)`); }; -window.addEventListener("load", handler); -window.addEventListener("beforeunload", handler); -window.addEventListener("unload", handler); +globalThis.addEventListener("load", handler); +globalThis.addEventListener("beforeunload", handler); +globalThis.addEventListener("unload", handler); console.log("log from nest_imported script"); |
