Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 3716316

Browse files
committed
Remove unneeded explicit globalThis in ServiceWorkerGlobalScope
1 parent a7fb38c commit 3716316

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/core/src/standards/event.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,7 @@ export class ServiceWorkerGlobalScope extends WorkerGlobalScope {
191191
>();
192192

193193
// Global self-references
194-
// noinspection JSUnusedGlobalSymbols
195194
readonly global = this;
196-
// noinspection JSUnusedGlobalSymbols
197-
readonly globalThis = this;
198-
// noinspection JSUnusedGlobalSymbols
199195
readonly self = this;
200196

201197
constructor(

packages/core/test/standards/event.spec.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ test("ServiceWorkerGlobalScope: includes environment in globals if modules disab
6666
/^env is not defined\.\nAttempted to access binding using global in modules/,
6767
});
6868
});
69-
test("ServiceWorkerGlobalScope: includes global self-references", (t) => {
70-
const { globalScope } = t.context;
71-
t.is(globalScope.global, globalScope);
72-
t.is(globalScope.globalThis, globalScope);
73-
t.is(globalScope.self, globalScope);
74-
});
7569
test("ServiceWorkerGlobalScope: addEventListener: disabled if modules enabled", (t) => {
7670
const globalScope = new ServiceWorkerGlobalScope(new NoOpLog(), {}, {}, true);
7771
t.throws(() => globalScope.addEventListener("fetch", () => {}), {
@@ -109,12 +103,22 @@ test("ServiceWorkerGlobalScope: hides implementation details", (t) => {
109103
"addEventListener",
110104
"dispatchEvent",
111105
"global",
112-
"globalThis",
113106
"removeEventListener",
114107
"self",
115108
]);
116109
});
117110

111+
test("MiniflareCore: includes global self-references", async (t) => {
112+
t.plan(2);
113+
const mf = useMiniflare(
114+
{ BindingsPlugin },
115+
{
116+
globals: { t },
117+
script: "t.is(global, globalThis); t.is(self, global);",
118+
}
119+
);
120+
await mf.getPlugins();
121+
});
118122
test("MiniflareCore: adds fetch event listener", async (t) => {
119123
const script = `(${(() => {
120124
const sandbox = self as any;

0 commit comments

Comments
 (0)