mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
6de2673a9f
Enables `--experimental-global-webcrypto` by default, and ensures that the classic `node:crypto` core module is still available in `--eval` or `--print` contexts. PR-URL: https://github.com/nodejs/node/pull/42083 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
22 lines
589 B
JavaScript
22 lines
589 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
assert.fail('When Node.js is compiled without OpenSSL, overriding the global ' +
|
|
'crypto is allowed on string eval');
|
|
}
|
|
|
|
const child = require('child_process');
|
|
const nodejs = `"${process.execPath}"`;
|
|
|
|
// Trying to define a variable named `crypto` using `var` triggers an exception.
|
|
|
|
child.exec(
|
|
`${nodejs} ` +
|
|
'-p "var crypto = {randomBytes:1};typeof crypto.randomBytes"',
|
|
common.mustSucceed((stdout) => {
|
|
assert.match(stdout, /^number/);
|
|
}));
|