| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ test('Aborted with gc cleanup', async () => { | |||
| 32 | 32 | const { promise, resolve } = Promise.withResolvers(); | |
| 33 | 33 | ||
| 34 | 34 | setImmediate(() => { | |
| 35 | - global.gc(); | ||
| 35 | + globalThis.gc(); | ||
| 36 | 36 | ac.abort(); | |
| 37 | 37 | strictEqual(ac.signal.aborted, true); | |
| 38 | 38 | strictEqual(getEventListeners(ac.signal, 'abort').length, 0); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ function makeSubsequentCalls(limit, done, holdReferences = false) { | |||
| 16 | 16 | // This setImmediate is necessary to ensure that in the last iteration the remaining signal is GCed (if not | |
| 17 | 17 | // retained) | |
| 18 | 18 | setImmediate(() => { | |
| 19 | - global.gc(); | ||
| 19 | + globalThis.gc(); | ||
| 20 | 20 | done(ac.signal, dependantSymbol); | |
| 21 | 21 | }); | |
| 22 | 22 | return; | |
@@ -50,7 +50,7 @@ function runShortLivedSourceSignal(limit, done) { | |||
| 50 | 50 | ||
| 51 | 51 | function run(iteration) { | |
| 52 | 52 | if (iteration > limit) { | |
| 53 | - global.gc(); | ||
| 53 | + globalThis.gc(); | ||
| 54 | 54 | done(signalRefs); | |
| 55 | 55 | return; | |
| 56 | 56 | } | |
@@ -74,9 +74,9 @@ function runWithOrphanListeners(limit, done) { | |||
| 74 | 74 | const ac = new AbortController(); | |
| 75 | 75 | if (iteration > limit) { | |
| 76 | 76 | setImmediate(() => { | |
| 77 | - global.gc(); | ||
| 77 | + globalThis.gc(); | ||
| 78 | 78 | setImmediate(() => { | |
| 79 | - global.gc(); | ||
| 79 | + globalThis.gc(); | ||
| 80 | 80 | ||
| 81 | 81 | done(composedSignalRefs); | |
| 82 | 82 | }); | |
@@ -147,7 +147,7 @@ it('drops settled dependant signals when signal is composite', (t, done) => { | |||
| 147 | 147 | t.assert.strictEqual(controllers[1].signal[kDependantSignals].size, 1); | |
| 148 | 148 | ||
| 149 | 149 | setImmediate(() => { | |
| 150 | - global.gc({ execution: 'async' }).then(async () => { | ||
| 150 | + globalThis.gc({ execution: 'async' }).then(async () => { | ||
| 151 | 151 | await gcUntil('all signals are GCed', () => { | |
| 152 | 152 | const totalDependantSignals = Math.max( | |
| 153 | 153 | controllers[0].signal[kDependantSignals].size, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,13 +49,13 @@ test('', { skip: !hasCrypto }, () => { | |||
| 49 | 49 | ||
| 50 | 50 | { // At the moment global has its own type tag | |
| 51 | 51 | const fakeGlobal = {}; | |
| 52 | - Object.setPrototypeOf(fakeGlobal, Object.getPrototypeOf(global)); | ||
| 53 | - for (const prop of Object.keys(global)) { | ||
| 52 | + Object.setPrototypeOf(fakeGlobal, Object.getPrototypeOf(globalThis)); | ||
| 53 | + for (const prop of Object.keys(globalThis)) { | ||
| 54 | 54 | fakeGlobal[prop] = global[prop]; | |
| 55 | 55 | } | |
| 56 | - assert.notDeepEqual(fakeGlobal, global); | ||
| 56 | + assert.notDeepEqual(fakeGlobal, globalThis); | ||
| 57 | 57 | // Message will be truncated anyway, don't validate | |
| 58 | - assert.throws(() => assert.deepStrictEqual(fakeGlobal, global), | ||
| 58 | + assert.throws(() => assert.deepStrictEqual(fakeGlobal, globalThis), | ||
| 59 | 59 | assert.AssertionError); | |
| 60 | 60 | } | |
| 61 | 61 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,6 @@ let asyncId = null; | |||
| 22 | 22 | } | |
| 23 | 23 | ||
| 24 | 24 | setImmediate(() => { | |
| 25 | - global.gc(); | ||
| 25 | + globalThis.gc(); | ||
| 26 | 26 | setImmediate(() => assert.ok(destroyedIds.has(asyncId))); | |
| 27 | 27 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ const hook = async_hooks.createHook({ | |||
| 14 | 14 | new async_hooks.AsyncResource('foobar', { requireManualDestroy: true }); | |
| 15 | 15 | ||
| 16 | 16 | setImmediate(() => { | |
| 17 | - global.gc(); | ||
| 17 | + globalThis.gc(); | ||
| 18 | 18 | setImmediate(() => { | |
| 19 | 19 | hook.disable(); | |
| 20 | 20 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,7 +17,7 @@ const hook = async_hooks.createHook({ | |||
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | 19 | setImmediate(() => { | |
| 20 | - global.gc(); | ||
| 20 | + globalThis.gc(); | ||
| 21 | 21 | setImmediate(() => { | |
| 22 | 22 | hook.disable(); | |
| 23 | 23 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -345,7 +345,7 @@ child.exec( | |||
| 345 | 345 | // Regression test for https://github.com/nodejs/node/issues/45336 | |
| 346 | 346 | child.execFile(process.execPath, | |
| 347 | 347 | ['-p', | |
| 348 | - 'Object.defineProperty(global, "fs", { configurable: false });' + | ||
| 348 | + 'Object.defineProperty(globalThis, "fs", { configurable: false });' + | ||
| 349 | 349 | 'fs === require("node:fs")'], | |
| 350 | 350 | common.mustSucceed((stdout) => { | |
| 351 | 351 | assert.match(stdout, /^true/); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,10 +5,10 @@ const { onGC } = require('../common/gc'); | |||
| 5 | 5 | ||
| 6 | 6 | { | |
| 7 | 7 | onGC({}, { ongc: common.mustCall() }); | |
| 8 | - global.gc(); | ||
| 8 | + globalThis.gc(); | ||
| 9 | 9 | } | |
| 10 | 10 | ||
| 11 | 11 | { | |
| 12 | 12 | onGC(process, { ongc: common.mustNotCall() }); | |
| 13 | - global.gc(); | ||
| 13 | + globalThis.gc(); | ||
| 14 | 14 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,28 +1,28 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - // Patch global.console before importing modules that may modify the console | ||
| 3 | + // Patch globalThis.console before importing modules that may modify the console | ||
| 4 | 4 | // object. | |
| 5 | 5 | ||
| 6 | - const tmp = global.console; | ||
| 7 | - global.console = 42; | ||
| 6 | + const tmp = globalThis.console; | ||
| 7 | + globalThis.console = 42; | ||
| 8 | 8 | ||
| 9 | 9 | require('../common'); | |
| 10 | 10 | const assert = require('assert'); | |
| 11 | 11 | ||
| 12 | 12 | // Originally the console had a getter. Test twice to verify it had no side | |
| 13 | 13 | // effect. | |
| 14 | - assert.strictEqual(global.console, 42); | ||
| 15 | - assert.strictEqual(global.console, 42); | ||
| 14 | + assert.strictEqual(globalThis.console, 42); | ||
| 15 | + assert.strictEqual(globalThis.console, 42); | ||
| 16 | 16 | ||
| 17 | 17 | assert.throws( | |
| 18 | 18 | () => console.log('foo'), | |
| 19 | 19 | { name: 'TypeError' } | |
| 20 | 20 | ); | |
| 21 | 21 | ||
| 22 | - global.console = 1; | ||
| 23 | - assert.strictEqual(global.console, 1); | ||
| 22 | + globalThis.console = 1; | ||
| 23 | + assert.strictEqual(globalThis.console, 1); | ||
| 24 | 24 | assert.strictEqual(console, 1); | |
| 25 | 25 | ||
| 26 | 26 | // Reset the console | |
| 27 | - global.console = tmp; | ||
| 27 | + globalThis.console = tmp; | ||
| 28 | 28 | console.log('foo'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,9 +36,9 @@ process.stdout.write = process.stderr.write = common.mustNotCall(); | |||
| 36 | 36 | // Make sure that the "Console" function exists. | |
| 37 | 37 | assert.strictEqual(typeof Console, 'function'); | |
| 38 | 38 | ||
| 39 | - assert.strictEqual(requiredConsole, global.console); | ||
| 39 | + assert.strictEqual(requiredConsole, globalThis.console); | ||
| 40 | 40 | // Make sure the custom instanceof of Console works | |
| 41 | - assert.ok(global.console instanceof Console); | ||
| 41 | + assert.ok(globalThis.console instanceof Console); | ||
| 42 | 42 | assert.ok(!({} instanceof Console)); | |
| 43 | 43 | ||
| 44 | 44 | // Make sure that the Console constructor throws | |
| Back | FazBrowse Home | New Git URL |
0 commit comments