@@ -49,6 +49,7 @@ const {
4949 ReflectGet,
5050 ReflectSet,
5151 SymbolToStringTag,
52+ globalThis,
5253} = primordials ;
5354const config = internalBinding ( 'config' ) ;
5455const { deprecate } = require ( 'internal/util' ) ;
@@ -189,61 +190,62 @@ if (!config.noBrowserGlobals) {
189190 // Override global console from the one provided by the VM
190191 // to the one implemented by Node.js
191192 // https://console.spec.whatwg.org/#console-namespace
192- exposeNamespace ( global , 'console' , createGlobalConsole ( global . console ) ) ;
193+ exposeNamespace ( globalThis , 'console' ,
194+ createGlobalConsole ( globalThis . console ) ) ;
193195
194196 const { URL , URLSearchParams } = require ( 'internal/url' ) ;
195197 // https://url.spec.whatwg.org/#url
196- exposeInterface ( global , 'URL' , URL ) ;
198+ exposeInterface ( globalThis , 'URL' , URL ) ;
197199 // https://url.spec.whatwg.org/#urlsearchparams
198- exposeInterface ( global , 'URLSearchParams' , URLSearchParams ) ;
200+ exposeInterface ( globalThis , 'URLSearchParams' , URLSearchParams ) ;
199201
200202 const {
201203 TextEncoder, TextDecoder
202204 } = require ( 'internal/encoding' ) ;
203205 // https://encoding.spec.whatwg.org/#textencoder
204- exposeInterface ( global , 'TextEncoder' , TextEncoder ) ;
206+ exposeInterface ( globalThis , 'TextEncoder' , TextEncoder ) ;
205207 // https://encoding.spec.whatwg.org/#textdecoder
206- exposeInterface ( global , 'TextDecoder' , TextDecoder ) ;
208+ exposeInterface ( globalThis , 'TextDecoder' , TextDecoder ) ;
207209
208210 const {
209211 AbortController,
210212 AbortSignal,
211213 } = require ( 'internal/abort_controller' ) ;
212- exposeInterface ( global , 'AbortController' , AbortController ) ;
213- exposeInterface ( global , 'AbortSignal' , AbortSignal ) ;
214+ exposeInterface ( globalThis , 'AbortController' , AbortController ) ;
215+ exposeInterface ( globalThis , 'AbortSignal' , AbortSignal ) ;
214216
215217 const {
216218 EventTarget,
217219 Event,
218220 } = require ( 'internal/event_target' ) ;
219- exposeInterface ( global , 'EventTarget' , EventTarget ) ;
220- exposeInterface ( global , 'Event' , Event ) ;
221+ exposeInterface ( globalThis , 'EventTarget' , EventTarget ) ;
222+ exposeInterface ( globalThis , 'Event' , Event ) ;
221223 const {
222224 MessageChannel,
223225 MessagePort,
224226 MessageEvent,
225227 } = require ( 'internal/worker/io' ) ;
226- exposeInterface ( global , 'MessageChannel' , MessageChannel ) ;
227- exposeInterface ( global , 'MessagePort' , MessagePort ) ;
228- exposeInterface ( global , 'MessageEvent' , MessageEvent ) ;
228+ exposeInterface ( globalThis , 'MessageChannel' , MessageChannel ) ;
229+ exposeInterface ( globalThis , 'MessagePort' , MessagePort ) ;
230+ exposeInterface ( globalThis , 'MessageEvent' , MessageEvent ) ;
229231
230232 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
231233 const timers = require ( 'timers' ) ;
232- defineOperation ( global , 'clearInterval' , timers . clearInterval ) ;
233- defineOperation ( global , 'clearTimeout' , timers . clearTimeout ) ;
234- defineOperation ( global , 'setInterval' , timers . setInterval ) ;
235- defineOperation ( global , 'setTimeout' , timers . setTimeout ) ;
234+ defineOperation ( globalThis , 'clearInterval' , timers . clearInterval ) ;
235+ defineOperation ( globalThis , 'clearTimeout' , timers . clearTimeout ) ;
236+ defineOperation ( globalThis , 'setInterval' , timers . setInterval ) ;
237+ defineOperation ( globalThis , 'setTimeout' , timers . setTimeout ) ;
236238
237- defineOperation ( global , 'queueMicrotask' , queueMicrotask ) ;
239+ defineOperation ( globalThis , 'queueMicrotask' , queueMicrotask ) ;
238240
239- defineLazyGlobal ( global , 'performance' , ( ) => {
241+ defineLazyGlobal ( globalThis , 'performance' , ( ) => {
240242 const { performance } = require ( 'perf_hooks' ) ;
241243 return performance ;
242244 } ) ;
243245
244246 // Non-standard extensions:
245- defineOperation ( global , 'clearImmediate' , timers . clearImmediate ) ;
246- defineOperation ( global , 'setImmediate' , timers . setImmediate ) ;
247+ defineOperation ( globalThis , 'clearImmediate' , timers . clearImmediate ) ;
248+ defineOperation ( globalThis , 'setImmediate' , timers . setImmediate ) ;
247249}
248250
249251// Set the per-Environment callback that will be called
@@ -388,7 +390,7 @@ function setupProcessObject() {
388390 value : 'process'
389391 } ) ;
390392 // Make process globally available to users by putting it on the global proxy
391- ObjectDefineProperty ( global , 'process' , {
393+ ObjectDefineProperty ( globalThis , 'process' , {
392394 value : process ,
393395 enumerable : false ,
394396 writable : true ,
@@ -397,7 +399,7 @@ function setupProcessObject() {
397399}
398400
399401function setupGlobalProxy ( ) {
400- ObjectDefineProperty ( global , SymbolToStringTag , {
402+ ObjectDefineProperty ( globalThis , SymbolToStringTag , {
401403 value : 'global' ,
402404 writable : false ,
403405 enumerable : false ,
@@ -418,7 +420,7 @@ function setupBuffer() {
418420 delete bufferBinding . setBufferPrototype ;
419421 delete bufferBinding . zeroFill ;
420422
421- ObjectDefineProperties ( global , {
423+ ObjectDefineProperties ( globalThis , {
422424 'Buffer' : {
423425 value : Buffer ,
424426 enumerable : false ,
0 commit comments