From 3860002ac678370756228eb0b96e10a2072a4494 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 26 Oct 2023 18:35:13 +0200 Subject: [PATCH 1/2] lib: add `--no-experimental-global-navigator` CLI flag --- doc/api/cli.md | 12 ++++++++++++ doc/api/globals.md | 15 +++++---------- .../bootstrap/web/exposed-window-or-worker.js | 4 ---- lib/internal/process/pre_execution.js | 14 ++++++++++++++ src/node_options.cc | 4 ++++ src/node_options.h | 1 + 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 5f29c497426db6..b5abacc401750c 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1196,6 +1196,16 @@ added: v19.0.0 Disable exposition of [CustomEvent Web API][] on the global scope. +### `--no-experimental-global-navigator` + + + +> Stability: 1 - Experimental + +Disable exposition of [Navigator API][] on the global scope. + ### `--no-experimental-global-webcrypto` -> Stability: 1.1 - Active development +> Stability: 1.1 - Active development. Disable this API with the +> [`--no-experimental-global-navigator`][] CLI flag. A partial implementation of the [Navigator API][]. @@ -610,18 +611,11 @@ A partial implementation of the [Navigator API][]. added: v21.0.0 --> -> Stability: 1.1 - Active development +> Stability: 1.1 - Active development. Disable this API with the +> [`--no-experimental-global-navigator`][] CLI flag. A partial implementation of [`window.navigator`][]. -If your app or a dependency uses a check for `navigator` to determine whether it -is running in a browser, the following can be used to delete the `navigator` -global before app code runs: - -```bash -node --import 'data:text/javascript,delete globalThis.navigator' app.js -``` - ### `navigator.hardwareConcurrency`