mirror of
https://github.com/denoland/deno.git
synced 2024-12-26 00:59:24 -05:00
fix: prevent Deno.exit to fail when dispatchEvent tampered (#14665)
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
0a96cb62a8
commit
e7c894e8f5
3 changed files with 12 additions and 1 deletions
|
@ -922,6 +922,12 @@ itest!(set_exit_code_in_worker {
|
|||
exit_code: 42,
|
||||
});
|
||||
|
||||
itest!(deno_exit_tampering {
|
||||
args: "run --no-check --unstable deno_exit_tampering.ts",
|
||||
output: "empty.out",
|
||||
exit_code: 42,
|
||||
});
|
||||
|
||||
itest!(heapstats {
|
||||
args: "run --quiet --unstable --v8-flags=--expose-gc heapstats.js",
|
||||
output: "heapstats.js.out",
|
||||
|
|
3
cli/tests/testdata/deno_exit_tampering.ts
vendored
Normal file
3
cli/tests/testdata/deno_exit_tampering.ts
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
delete globalThis.dispatchEvent;
|
||||
delete EventTarget.prototype.dispatchEvent;
|
||||
Deno.exit(42);
|
|
@ -8,6 +8,8 @@
|
|||
SymbolFor,
|
||||
} = window.__bootstrap.primordials;
|
||||
|
||||
const windowDispatchEvent = window.dispatchEvent.bind(window);
|
||||
|
||||
function loadavg() {
|
||||
return core.opSync("op_loadavg");
|
||||
}
|
||||
|
@ -51,7 +53,7 @@
|
|||
if (!window[SymbolFor("isUnloadDispatched")]) {
|
||||
// Invokes the `unload` hooks before exiting
|
||||
// ref: https://github.com/denoland/deno/issues/3603
|
||||
window.dispatchEvent(new Event("unload"));
|
||||
windowDispatchEvent(new Event("unload"));
|
||||
}
|
||||
|
||||
if (exitHandler) {
|
||||
|
|
Loading…
Reference in a new issue