summaryrefslogtreecommitdiff
path: root/tests/testdata/run/before_unload.js
blob: 2572e512b916620c545791f98345549c4f915a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);