mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
dcc5e51e1c
PR-URL: https://github.com/nodejs/node/pull/27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
30 lines
1007 B
JavaScript
30 lines
1007 B
JavaScript
// Flags: --no-warnings
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const vm = require('vm');
|
|
const assert = require('assert');
|
|
|
|
if (new Error().stack.includes('node_modules'))
|
|
common.skip('test does not work when inside `node_modules` directory');
|
|
if (process.env.NODE_PENDING_DEPRECATION)
|
|
common.skip('test does not work when NODE_PENDING_DEPRECATION is set');
|
|
|
|
const bufferWarning = 'Buffer() is deprecated due to security and usability ' +
|
|
'issues. Please use the Buffer.alloc(), ' +
|
|
'Buffer.allocUnsafe(), or Buffer.from() methods instead.';
|
|
|
|
process.addListener('warning', common.mustCall((warning) => {
|
|
assert(warning.stack.includes('this_should_emit_a_warning'), warning.stack);
|
|
}));
|
|
|
|
vm.runInNewContext('new Buffer(10)', { Buffer }, {
|
|
filename: '/a/node_modules/b'
|
|
});
|
|
|
|
common.expectWarning('DeprecationWarning', bufferWarning, 'DEP0005');
|
|
|
|
vm.runInNewContext('new Buffer(10)', { Buffer }, {
|
|
filename: '/this_should_emit_a_warning'
|
|
});
|