diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-08-29 00:56:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 01:56:15 +0200 |
commit | 57541b48ba0402a8ff4a1e30c7e326fe9edab241 (patch) | |
tree | 1f3ec518b5e4fdcbd4366be8057c5c31276bac92 /tests/testdata/run/onload/main.ts | |
parent | 3afa3db4d394b0e63e63ad4e09645f74eea39c4a (diff) |
test: replace usage of `window` with `globalThis` (#25284)
Fixes several tests blocking https://github.com/denoland/deno/pull/25213
by replacing `window` global that is gone in Deno 2 with `globalThis`.
Also adjusted a few tests using deprecated `rid` field.
Diffstat (limited to 'tests/testdata/run/onload/main.ts')
-rw-r--r-- | tests/testdata/run/onload/main.ts | 18 |
1 files changed, 9 insertions, 9 deletions
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`); }; |