summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/before_unload.js
diff options
context:
space:
mode:
authorColin Ihrig <cjihrig@gmail.com>2022-06-28 10:49:30 -0400
committerGitHub <noreply@github.com>2022-06-28 10:49:30 -0400
commit0f6a5c5fc24e8dc9125c5c536c8547a86ca87b15 (patch)
tree41538ee1df06dc80d60e49ed50177f99ba8dc297 /cli/tests/testdata/before_unload.js
parentab11b45d1d2678cfea2217ac72fc24317eef777d (diff)
feat(web): add beforeunload event (#14830)
This commit adds the 'beforeunload' event. Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tests/testdata/before_unload.js')
-rw-r--r--cli/tests/testdata/before_unload.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/cli/tests/testdata/before_unload.js b/cli/tests/testdata/before_unload.js
new file mode 100644
index 000000000..2572e512b
--- /dev/null
+++ b/cli/tests/testdata/before_unload.js
@@ -0,0 +1,21 @@
+let count = 0;
+
+console.log("0");
+
+globalThis.addEventListener("beforeunload", (e) => {
+ console.log("GOT EVENT");
+ if (count === 0 || count === 1) {
+ e.preventDefault();
+ setTimeout(() => {
+ console.log("3");
+ }, 100);
+ }
+
+ count++;
+});
+
+console.log("1");
+
+setTimeout(() => {
+ console.log("2");
+}, 100);