mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
Currently, when configured --without-ssl tests that use
process.binding('crypto') fail with the following error:
=== release test-accessor-properties ===
Path: parallel/test-accessor-properties
node/test/parallel/test-accessor-properties.js:16
const crypto = process.binding('crypto');
^
Error: No such module: crypto
at Object.<anonymous> (test-accessor-properties.js:16:24)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:577:32)
at tryModuleLoad (module.js:517:12)
at Function.Module._load (module.js:509:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:645:3
This commit adds a hasCrypto check.
Backport-PR-URL: https://github.com/nodejs/node/pull/20456
PR-URL: https://github.com/nodejs/node/pull/17867
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
79 lines
1.8 KiB
JavaScript
79 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// This tests that the accessor properties do not raise assertions
|
|
// when called with incompatible receivers.
|
|
|
|
const assert = require('assert');
|
|
|
|
// Objects that call StreamBase::AddMethods, when setting up
|
|
// their prototype
|
|
const TTY = process.binding('tty_wrap').TTY;
|
|
const UDP = process.binding('udp_wrap').UDP;
|
|
|
|
{
|
|
// Should throw instead of raise assertions
|
|
assert.throws(() => {
|
|
TTY.prototype.bytesRead;
|
|
}, TypeError);
|
|
|
|
assert.throws(() => {
|
|
TTY.prototype.fd;
|
|
}, TypeError);
|
|
|
|
assert.throws(() => {
|
|
TTY.prototype._externalStream;
|
|
}, TypeError);
|
|
|
|
assert.throws(() => {
|
|
UDP.prototype.fd;
|
|
}, TypeError);
|
|
|
|
// Should not throw for Object.getOwnPropertyDescriptor
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'),
|
|
'object'
|
|
);
|
|
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'fd'),
|
|
'object'
|
|
);
|
|
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(TTY.prototype, '_externalStream'),
|
|
'object'
|
|
);
|
|
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(UDP.prototype, 'fd'),
|
|
'object'
|
|
);
|
|
|
|
if (common.hasCrypto) { // eslint-disable-line crypto-check
|
|
// There are accessor properties in crypto too
|
|
const crypto = process.binding('crypto');
|
|
|
|
assert.throws(() => {
|
|
crypto.SecureContext.prototype._external;
|
|
}, TypeError);
|
|
|
|
assert.throws(() => {
|
|
crypto.Connection.prototype._external;
|
|
}, TypeError);
|
|
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(
|
|
crypto.SecureContext.prototype, '_external'),
|
|
'object'
|
|
);
|
|
|
|
assert.strictEqual(
|
|
typeof Object.getOwnPropertyDescriptor(
|
|
crypto.Connection.prototype, '_external'),
|
|
'object'
|
|
);
|
|
}
|
|
}
|