summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2024-07-19 12:37:08 +0900
committerGitHub <noreply@github.com>2024-07-19 12:37:08 +0900
commit76b8ecbb6d8c07d29c34fb0b301cc3bf3351e3aa (patch)
tree228b5bde74244c0a844d61257530d1b8e2eef9e4 /tests
parent3bda8eb4fe059fd79a522c9277a5a872f75dc270 (diff)
fix(ext/node): do not expose `self` global in node (#24637)
closes #23727
Diffstat (limited to 'tests')
-rw-r--r--tests/registry/npm/@denotest/globals/1.0.0/index.d.ts3
-rw-r--r--tests/registry/npm/@denotest/globals/1.0.0/index.js7
-rw-r--r--tests/testdata/npm/compare_globals/main.out4
-rw-r--r--tests/testdata/npm/compare_globals/main.ts7
4 files changed, 18 insertions, 3 deletions
diff --git a/tests/registry/npm/@denotest/globals/1.0.0/index.d.ts b/tests/registry/npm/@denotest/globals/1.0.0/index.d.ts
index 1bbb82047..76dd781db 100644
--- a/tests/registry/npm/@denotest/globals/1.0.0/index.d.ts
+++ b/tests/registry/npm/@denotest/globals/1.0.0/index.d.ts
@@ -17,5 +17,6 @@ export function getSetTimeout(): typeof setTimeout;
export function checkProcessGlobal(): void;
export function checkWindowGlobal(): void;
+export function checkSelfGlobal(): void;
-export function getFoo(): string; \ No newline at end of file
+export function getFoo(): string;
diff --git a/tests/registry/npm/@denotest/globals/1.0.0/index.js b/tests/registry/npm/@denotest/globals/1.0.0/index.js
index b946bbd2a..64f913b37 100644
--- a/tests/registry/npm/@denotest/globals/1.0.0/index.js
+++ b/tests/registry/npm/@denotest/globals/1.0.0/index.js
@@ -20,6 +20,11 @@ exports.checkWindowGlobal = function () {
console.log(Object.getOwnPropertyDescriptor(globalThis, "window") !== undefined);
}
+exports.checkSelfGlobal = function () {
+ console.log("self" in globalThis);
+ console.log(Object.getOwnPropertyDescriptor(globalThis, "self") !== undefined);
+}
+
exports.getFoo = function () {
return globalThis.foo;
-} \ No newline at end of file
+}
diff --git a/tests/testdata/npm/compare_globals/main.out b/tests/testdata/npm/compare_globals/main.out
index 5af536657..9c9c2203a 100644
--- a/tests/testdata/npm/compare_globals/main.out
+++ b/tests/testdata/npm/compare_globals/main.out
@@ -21,6 +21,10 @@ true
true
true
true
+true
+true
+false
+false
false
false
bar
diff --git a/tests/testdata/npm/compare_globals/main.ts b/tests/testdata/npm/compare_globals/main.ts
index 6f7b9ef8e..5d082386f 100644
--- a/tests/testdata/npm/compare_globals/main.ts
+++ b/tests/testdata/npm/compare_globals/main.ts
@@ -37,12 +37,17 @@ console.log(
);
globals.checkProcessGlobal();
-// In Deno, the window global is defined, but in Node it is not.
+// In Deno, the window and self globals are defined, but in Node they are not.
console.log("window" in globalThis);
+console.log("self" in globalThis);
console.log(
Object.getOwnPropertyDescriptor(globalThis, "window") !== undefined,
);
+console.log(
+ Object.getOwnPropertyDescriptor(globalThis, "self") !== undefined,
+);
globals.checkWindowGlobal();
+globals.checkSelfGlobal();
// "Non-managed" globals are shared between Node and Deno.
(globalThis as any).foo = "bar";