From d810a7bc2a8216718f189ad3b9105d24e1ae0cf7 Mon Sep 17 00:00:00 2001 From: Gabriel Bota <94833492+dygabo@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:42:46 +0200 Subject: [PATCH] lib: fix the name of the fetch global function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/53227 Reviewed-By: Matteo Collina Reviewed-By: Yagiz Nizipli Reviewed-By: Michaƫl Zasso Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Matthew Aitken Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel Reviewed-By: Moshe Atlow --- lib/internal/bootstrap/web/exposed-window-or-worker.js | 2 +- test/parallel/test-global.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/internal/bootstrap/web/exposed-window-or-worker.js b/lib/internal/bootstrap/web/exposed-window-or-worker.js index a1bfd54107a2c7..1d07b3eda07ad9 100644 --- a/lib/internal/bootstrap/web/exposed-window-or-worker.js +++ b/lib/internal/bootstrap/web/exposed-window-or-worker.js @@ -70,7 +70,7 @@ ObjectDefineProperty(globalThis, 'fetch', { configurable: true, enumerable: true, writable: true, - value: function value(input, init = undefined) { + value: function fetch(input, init = undefined) { // eslint-disable-line func-name-matching if (!fetchImpl) { // Implement lazy loading of undici module for fetch function const undiciModule = require('internal/deps/undici/undici'); fetchImpl = undiciModule.fetch; diff --git a/test/parallel/test-global.js b/test/parallel/test-global.js index d31b1d97744ff8..37f4db5252be5c 100644 --- a/test/parallel/test-global.js +++ b/test/parallel/test-global.js @@ -61,6 +61,14 @@ for (const moduleName of builtinModules) { 'navigator', ]; assert.deepStrictEqual(new Set(Object.keys(global)), new Set(expected)); + expected.forEach((value) => { + const desc = Object.getOwnPropertyDescriptor(global, value); + if (typeof desc.value === 'function') { + assert.strictEqual(desc.value.name, value); + } else if (typeof desc.get === 'function') { + assert.strictEqual(desc.get.name, `get ${value}`); + } + }); } common.allowGlobals('bar', 'foo');