summaryrefslogtreecommitdiff
path: root/tests/testdata/run/replace_self.js
blob: cfd473cd3f70fb1e25dca5415414c1ccbde22ad6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Test that setting `self` in the main thread to some other value doesn't break
// the world, in particular for events fired on the global scope.

// deno-lint-ignore no-global-assign
self = null;

addEventListener("load", () => {
  console.log("load event (event listener)");
});

addEventListener("unload", () => {
  console.log("unload event (event listener)");
});

globalThis.onload = () => {
  console.log("load event (event handler)");
};

globalThis.onunload = () => {
  console.log("unload event (event handler)");
};