From 5ea766ba77b19409709d452f1b713df5fd8fb380 Mon Sep 17 00:00:00 2001 From: Khafra Date: Fri, 7 Jun 2024 13:54:28 -0400 Subject: [PATCH] lib: expose global CloseEvent This PR adds `CloseEvent` as a global, which can be disabled via the --no-experimental-websocket flag. ```js const ws = new WebSocket('...') ws.addEventListener('close', (event) => { assert(event instanceof CloseEvent) }) ``` Fixes: https://github.com/nodejs/node/issues/50275 PR-URL: https://github.com/nodejs/node/pull/53355 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Paolo Insogna Reviewed-By: Matteo Collina Reviewed-By: Chemi Atlow --- doc/api/globals.md | 14 ++++++++++++++ lib/eslint.config_partial.mjs | 4 ++++ .../bootstrap/web/exposed-window-or-worker.js | 2 +- lib/internal/process/pre_execution.js | 1 + test/common/globals.js | 1 + test/eslint.config_partial.mjs | 1 + test/parallel/test-websocket-disabled.js | 1 + test/parallel/test-websocket.js | 1 + 8 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/api/globals.md b/doc/api/globals.md index 836201d3ac31dc..011032c18330cf 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -322,6 +322,19 @@ added: v0.0.1 [`clearTimeout`][] is described in the [timers][] section. +## `CloseEvent` + + + + + +The `CloseEvent` class. See [`CloseEvent`][] for more details. + +A browser-compatible implementation of [`CloseEvent`][]. Disable this API +with the [`--no-experimental-websocket`][] CLI flag. + ## Class: `CompressionStream`