From 309c71ae38e0f29fd3d563bfc2766f4aa94eb0ad Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 8 Nov 2023 19:24:51 +0200 Subject: [PATCH] lib: add `--no-experimental-global-navigator` CLI flag PR-URL: https://github.com/nodejs/node/pull/50562 Reviewed-By: Matteo Collina Reviewed-By: Geoffrey Booth Reviewed-By: Chengzhong Wu Reviewed-By: Richard Lau Reviewed-By: Ethan Arrowood --- 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 | 5 +++++ src/node_options.h | 1 + 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 1bd4864b2d1bca..1f5136ce69442f 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`