node/test/parallel/test-domain-crypto.js
Rich Trott a7b3a7533a test: be explicit about polluting of global
There was a comment in `test-domain-crypto.js` indicating that the
pollution of the `global` object with a `domain` property was
intentional. Provide more information in the comment so someone may
easily determine why. Use `global.domain` rather than declaring `domain`
without the `var` keyword to more clearly signal that the pollution is
intentional.

PR-URL: https://github.com/nodejs/node/pull/6017
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-04-11 12:55:01 -04:00

18 lines
586 B
JavaScript

/* eslint-disable strict, required-modules */
try {
var crypto = require('crypto');
} catch (e) {
console.log('1..0 # Skipped: node compiled without OpenSSL.');
return;
}
// Pollution of global is intentional as part of test.
// See https://github.com/nodejs/node/commit/d1eff9ab
global.domain = require('domain');
// should not throw a 'TypeError: undefined is not a function' exception
crypto.randomBytes(8);
crypto.randomBytes(8, function() {});
crypto.pseudoRandomBytes(8);
crypto.pseudoRandomBytes(8, function() {});
crypto.pbkdf2('password', 'salt', 8, 8, function() {});