summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/034_onload
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-08-11 10:20:47 -0400
committerGitHub <noreply@github.com>2021-08-11 10:20:47 -0400
commit15a763152f9d392cb80692262f8de5ef8ae15495 (patch)
treefcd1a59777f95920bf3502519983d6cc0d882a9a /cli/tests/testdata/034_onload
parenta0285e2eb88f6254f6494b0ecd1878db3a3b2a58 (diff)
chore: move test files to testdata directory (#11601)
Diffstat (limited to 'cli/tests/testdata/034_onload')
-rw-r--r--cli/tests/testdata/034_onload/imported.ts11
-rw-r--r--cli/tests/testdata/034_onload/main.ts26
-rw-r--r--cli/tests/testdata/034_onload/nest_imported.ts10
3 files changed, 47 insertions, 0 deletions
diff --git a/cli/tests/testdata/034_onload/imported.ts b/cli/tests/testdata/034_onload/imported.ts
new file mode 100644
index 000000000..bac6cf5fa
--- /dev/null
+++ b/cli/tests/testdata/034_onload/imported.ts
@@ -0,0 +1,11 @@
+import { assert } from "../../../../test_util/std/testing/asserts.ts";
+import "./nest_imported.ts";
+
+const handler = (e: Event) => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in event handler (imported)`);
+};
+
+window.addEventListener("load", handler);
+window.addEventListener("unload", handler);
+console.log("log from imported script");
diff --git a/cli/tests/testdata/034_onload/main.ts b/cli/tests/testdata/034_onload/main.ts
new file mode 100644
index 000000000..42df21c16
--- /dev/null
+++ b/cli/tests/testdata/034_onload/main.ts
@@ -0,0 +1,26 @@
+import { assert } from "../../../../test_util/std/testing/asserts.ts";
+import "./imported.ts";
+
+assert(window.hasOwnProperty("onload"));
+assert(window.onload === null);
+
+const eventHandler = (e: Event) => {
+ 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) => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in onload function`);
+};
+
+window.onunload = (e: Event) => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in onunload function`);
+};
+
+console.log("log from main");
diff --git a/cli/tests/testdata/034_onload/nest_imported.ts b/cli/tests/testdata/034_onload/nest_imported.ts
new file mode 100644
index 000000000..259e505a2
--- /dev/null
+++ b/cli/tests/testdata/034_onload/nest_imported.ts
@@ -0,0 +1,10 @@
+import { assert } from "../../../../test_util/std/testing/asserts.ts";
+
+const handler = (e: Event) => {
+ assert(!e.cancelable);
+ console.log(`got ${e.type} event in event handler (nest_imported)`);
+};
+
+window.addEventListener("load", handler);
+window.addEventListener("unload", handler);
+console.log("log from nest_imported script");