mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +00:00

Some checks are pending
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
test-global-setters.js was added in https://github.com/nodejs/node/pull/26882 and hasn't been modified since. It appears that it avoids strict mode so that unscoped identifiers are treated as globals, but that's true in strict mode too. (In sloppy mode, an assignment to an undefined identifier will create a global, but that's not what this test does. In strict mode, those assignments will throw an error, which would seem to be what we would want.) PR-URL: https://github.com/nodejs/node/pull/56742 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
// When setters and getters were added for global.process and global.Buffer to
|
|
// create a deprecation path for them in ESM, this test was added to make sure
|
|
// the setters and getters behaved as expected.
|
|
// Ref: https://github.com/nodejs/node/pull/26882
|
|
// Ref: https://github.com/nodejs/node/pull/26334
|
|
|
|
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const _process = require('process');
|
|
const { Buffer: _Buffer } = require('buffer');
|
|
|
|
assert.strictEqual(process, _process);
|
|
// eslint-disable-next-line no-global-assign
|
|
process = 'asdf';
|
|
assert.strictEqual(process, 'asdf');
|
|
assert.strictEqual(globalThis.process, 'asdf');
|
|
globalThis.process = _process;
|
|
assert.strictEqual(process, _process);
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(globalThis, 'process').get,
|
|
'function');
|
|
|
|
assert.strictEqual(Buffer, _Buffer);
|
|
// eslint-disable-next-line no-global-assign
|
|
Buffer = 'asdf';
|
|
assert.strictEqual(Buffer, 'asdf');
|
|
assert.strictEqual(globalThis.Buffer, 'asdf');
|
|
globalThis.Buffer = _Buffer;
|
|
assert.strictEqual(Buffer, _Buffer);
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(globalThis, 'Buffer').get,
|
|
'function');
|