From 2a8db23fd8d19d0eb697c1cd18b74c53edb60ec2 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Mon, 23 Sep 2024 10:39:51 +0200 Subject: [PATCH] feat(cli): expose node `global` everywhere --- runtime/js/98_global_scope_shared.js | 1 + tests/specs/run/globals/__test__.jsonc | 9 +++++++++ tests/specs/run/globals/has_node_global.js | 1 + tests/specs/run/globals/has_node_global.out | 0 4 files changed, 11 insertions(+) create mode 100644 tests/specs/run/globals/__test__.jsonc create mode 100644 tests/specs/run/globals/has_node_global.js create mode 100644 tests/specs/run/globals/has_node_global.out diff --git a/runtime/js/98_global_scope_shared.js b/runtime/js/98_global_scope_shared.js index 7a27238996..5f96d53ddc 100644 --- a/runtime/js/98_global_scope_shared.js +++ b/runtime/js/98_global_scope_shared.js @@ -136,6 +136,7 @@ const windowOrWorkerGlobalScope = { Crypto: core.propNonEnumerable(crypto.Crypto), SubtleCrypto: core.propNonEnumerable(crypto.SubtleCrypto), fetch: core.propWritable(fetch.fetch), + global: core.propWritable(globalThis), EventSource: core.propWritable(eventSource.EventSource), performance: core.propWritable(performance.performance), process: core.propWritable(process), diff --git a/tests/specs/run/globals/__test__.jsonc b/tests/specs/run/globals/__test__.jsonc new file mode 100644 index 0000000000..89d2619720 --- /dev/null +++ b/tests/specs/run/globals/__test__.jsonc @@ -0,0 +1,9 @@ +{ + "tests": { + "has_node_global": { + "args": "run has_node_global.js", + "exitCode": 0, + "output": "has_node_global.out" + } + } +} diff --git a/tests/specs/run/globals/has_node_global.js b/tests/specs/run/globals/has_node_global.js new file mode 100644 index 0000000000..821f3683f9 --- /dev/null +++ b/tests/specs/run/globals/has_node_global.js @@ -0,0 +1 @@ +globalThis === globalThis.global; diff --git a/tests/specs/run/globals/has_node_global.out b/tests/specs/run/globals/has_node_global.out new file mode 100644 index 0000000000..e69de29bb2