From 8e0e8c7a9d54f0f052db42f40c67c68738b3e642 Mon Sep 17 00:00:00 2001 From: Vladimir Kurchatkin Date: Wed, 9 Sep 2015 14:44:50 +0300 Subject: [PATCH] node: deprecate public access to `process.binding` --- lib/_debugger.js | 2 +- lib/_http_client.js | 2 +- lib/_http_common.js | 2 +- lib/_http_server.js | 2 +- lib/_stream_wrap.js | 4 +-- lib/_tls_common.js | 2 +- lib/_tls_legacy.js | 4 +-- lib/_tls_wrap.js | 8 +++--- lib/assert.js | 2 +- lib/buffer.js | 2 +- lib/child_process.js | 6 ++--- lib/cluster.js | 2 +- lib/constants.js | 2 +- lib/crypto.js | 2 +- lib/dgram.js | 4 +-- lib/dns.js | 4 +-- lib/fs.js | 4 +-- lib/internal/child_process.js | 14 +++++----- lib/module.js | 4 +-- lib/net.js | 18 ++++++------- lib/os.js | 2 +- lib/timers.js | 2 +- lib/tls.js | 2 +- lib/tty.js | 4 +-- lib/util.js | 4 +-- lib/v8.js | 2 +- lib/vm.js | 2 +- lib/zlib.js | 2 +- src/node.cc | 6 ++--- src/node.js | 26 ++++++++++++------- test/common.js | 2 +- test/disabled/test-sendfd.js | 3 ++- test/internet/test-dns.js | 3 ++- .../test-async-wrap-check-providers.js | 6 ++--- ...st-async-wrap-disabled-propagate-parent.js | 4 +-- .../test-async-wrap-propagate-parent.js | 4 +-- test/parallel/test-dns-lookup-cb-error.js | 5 ++-- test/parallel/test-http-localaddress.js | 1 + test/parallel/test-http-parser-bad-ref.js | 4 +-- test/parallel/test-http-parser.js | 3 ++- test/parallel/test-http-regr-gh-2928.js | 3 ++- test/parallel/test-https-localaddress.js | 1 + .../test-js-stream-call-properties.js | 4 +-- test/parallel/test-net-persistent-nodelay.js | 3 ++- .../parallel/test-net-persistent-ref-unref.js | 3 ++- test/parallel/test-process-binding.js | 5 ++-- test/parallel/test-process-wrap.js | 5 ++-- test/parallel/test-signal-safety.js | 3 ++- test/parallel/test-stream-wrap.js | 3 ++- .../test-stringbytes-external-at-max.js | 4 +-- ...ingbytes-external-exceed-max-by-1-ascii.js | 4 +-- ...ngbytes-external-exceed-max-by-1-base64.js | 4 +-- ...ngbytes-external-exceed-max-by-1-binary.js | 4 +-- ...tringbytes-external-exceed-max-by-1-hex.js | 4 +-- ...ringbytes-external-exceed-max-by-1-utf8.js | 4 +-- ...st-stringbytes-external-exceed-max-by-2.js | 4 +-- .../test-stringbytes-external-exceed-max.js | 4 +-- test/parallel/test-stringbytes-external.js | 1 + test/parallel/test-tcp-wrap.js | 5 ++-- test/parallel/test-timer-close.js | 3 ++- test/parallel/test-timers-now.js | 4 +-- test/parallel/test-timers-ordering.js | 3 ++- test/parallel/test-timers-unref-call.js | 3 ++- test/parallel/test-tty-wrap.js | 5 ++-- test/pummel/test-timer-wrap.js | 3 ++- test/pummel/test-timer-wrap2.js | 3 ++- test/sequential/test-tcp-wrap-connect.js | 7 ++--- test/sequential/test-tcp-wrap-listen.js | 5 ++-- test/timers/test-timers-reliability.js | 3 ++- 69 files changed, 157 insertions(+), 127 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index 9f8fa26f2189c3..9681b15b922869 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -179,7 +179,7 @@ Client.prototype._addHandle = function(desc) { }; -const natives = process.binding('natives'); +const natives = require('binding/natives'); Client.prototype._addScript = function(desc) { diff --git a/lib/_http_client.js b/lib/_http_client.js index 201593e61da5ac..a5269b0c6d7257 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -4,7 +4,7 @@ const util = require('util'); const net = require('net'); const url = require('url'); const EventEmitter = require('events'); -const HTTPParser = process.binding('http_parser').HTTPParser; +const HTTPParser = require('binding/http_parser').HTTPParser; const assert = require('assert').ok; const common = require('_http_common'); const httpSocketSetup = common.httpSocketSetup; diff --git a/lib/_http_common.js b/lib/_http_common.js index 5140d366661cb4..502054056c01f7 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -1,7 +1,7 @@ 'use strict'; const FreeList = require('internal/freelist').FreeList; -const HTTPParser = process.binding('http_parser').HTTPParser; +const HTTPParser = require('binding/http_parser').HTTPParser; const incoming = require('_http_incoming'); const IncomingMessage = incoming.IncomingMessage; diff --git a/lib/_http_server.js b/lib/_http_server.js index dc7276d0ae729d..4daff0194e6446 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -3,7 +3,7 @@ const util = require('util'); const net = require('net'); const EventEmitter = require('events'); -const HTTPParser = process.binding('http_parser').HTTPParser; +const HTTPParser = require('binding/http_parser').HTTPParser; const assert = require('assert').ok; const common = require('_http_common'); const parsers = common.parsers; diff --git a/lib/_stream_wrap.js b/lib/_stream_wrap.js index 924d07a986a906..972da26d2dfd5a 100644 --- a/lib/_stream_wrap.js +++ b/lib/_stream_wrap.js @@ -3,8 +3,8 @@ const assert = require('assert'); const util = require('util'); const Socket = require('net').Socket; -const JSStream = process.binding('js_stream').JSStream; -const uv = process.binding('uv'); +const JSStream = require('binding/js_stream').JSStream; +const uv = require('binding/uv'); const debug = util.debuglog('stream_wrap'); function StreamWrap(stream) { diff --git a/lib/_tls_common.js b/lib/_tls_common.js index d857717dabae15..1dd7f11de1da89 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -6,7 +6,7 @@ const tls = require('tls'); // Lazily loaded var crypto = null; -const binding = process.binding('crypto'); +const binding = require('binding/crypto'); const NativeSecureContext = binding.SecureContext; function SecureContext(secureProtocol, flags, context) { diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index 1d700c9218f538..14b9c9e74cffa3 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -8,10 +8,10 @@ const util = require('util'); const common = require('_tls_common'); const debug = util.debuglog('tls-legacy'); const Buffer = require('buffer').Buffer; -const Timer = process.binding('timer_wrap').Timer; +const Timer = require('binding/timer_wrap').Timer; var Connection = null; try { - Connection = process.binding('crypto').Connection; + Connection = require('binding/crypto').Connection; } catch (e) { throw new Error('node.js not compiled with openssl crypto support.'); } diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index ae88bf6c18ebf6..38638af2fe4849 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -10,10 +10,10 @@ const StreamWrap = require('_stream_wrap').StreamWrap; const Buffer = require('buffer').Buffer; const Duplex = require('stream').Duplex; const debug = util.debuglog('tls'); -const Timer = process.binding('timer_wrap').Timer; -const tls_wrap = process.binding('tls_wrap'); -const TCP = process.binding('tcp_wrap').TCP; -const Pipe = process.binding('pipe_wrap').Pipe; +const Timer = require('binding/timer_wrap').Timer; +const tls_wrap = require('binding/tls_wrap'); +const TCP = require('binding/tcp_wrap').TCP; +const Pipe = require('binding/pipe_wrap').Pipe; function onhandshakestart() { debug('onhandshakestart'); diff --git a/lib/assert.js b/lib/assert.js index 6b99098c5fda35..5685618ec39b55 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -25,7 +25,7 @@ 'use strict'; // UTILITY -const compare = process.binding('buffer').compare; +const compare = require('binding/buffer').compare; const util = require('util'); const Buffer = require('buffer').Buffer; const pSlice = Array.prototype.slice; diff --git a/lib/buffer.js b/lib/buffer.js index 41d5e0aba2d536..deefe1f0266592 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -1,7 +1,7 @@ /* eslint-disable require-buffer */ 'use strict'; -const binding = process.binding('buffer'); +const binding = require('binding/buffer'); const internalUtil = require('internal/util'); const bindingObj = {}; diff --git a/lib/child_process.js b/lib/child_process.js index 0fe9ca75c7794a..eda87f9244cd18 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -5,10 +5,10 @@ const internalUtil = require('internal/util'); const debug = util.debuglog('child_process'); const constants = require('constants'); -const uv = process.binding('uv'); -const spawn_sync = process.binding('spawn_sync'); +const uv = require('binding/uv'); +const spawn_sync = require('binding/spawn_sync'); const Buffer = require('buffer').Buffer; -const Pipe = process.binding('pipe_wrap').Pipe; +const Pipe = require('binding/pipe_wrap').Pipe; const child_process = require('internal/child_process'); const errnoException = util._errnoException; diff --git a/lib/cluster.js b/lib/cluster.js index 602cc8d60b9200..820adc2b095c83 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -9,7 +9,7 @@ const util = require('util'); const SCHED_NONE = 1; const SCHED_RR = 2; -const uv = process.binding('uv'); +const uv = require('binding/uv'); const cluster = new EventEmitter(); module.exports = cluster; diff --git a/lib/constants.js b/lib/constants.js index 9fa017904ceb45..96385cf224af06 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -1,3 +1,3 @@ 'use strict'; -module.exports = process.binding('constants'); +module.exports = require('binding/constants'); diff --git a/lib/crypto.js b/lib/crypto.js index b32d9aff90b72b..ccf4ab60f718f7 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -6,7 +6,7 @@ exports.DEFAULT_ENCODING = 'buffer'; try { - var binding = process.binding('crypto'); + var binding = require('binding/crypto'); var randomBytes = binding.randomBytes; var getCiphers = binding.getCiphers; var getHashes = binding.getHashes; diff --git a/lib/dgram.js b/lib/dgram.js index eaf84272d16284..3e5127e798e960 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -6,8 +6,8 @@ const util = require('util'); const EventEmitter = require('events'); const constants = require('constants'); -const UDP = process.binding('udp_wrap').UDP; -const SendWrap = process.binding('udp_wrap').SendWrap; +const UDP = require('binding/udp_wrap').UDP; +const SendWrap = require('binding/udp_wrap').SendWrap; const BIND_STATE_UNBOUND = 0; const BIND_STATE_BINDING = 1; diff --git a/lib/dns.js b/lib/dns.js index 8bd61caee96066..6730b98c1cab13 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -3,8 +3,8 @@ const net = require('net'); const util = require('util'); -const cares = process.binding('cares_wrap'); -const uv = process.binding('uv'); +const cares = require('binding/cares_wrap'); +const uv = require('binding/uv'); const GetAddrInfoReqWrap = cares.GetAddrInfoReqWrap; const GetNameInfoReqWrap = cares.GetNameInfoReqWrap; diff --git a/lib/fs.js b/lib/fs.js index fef4f7ba501b50..5adb8acf037a4a 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -7,14 +7,14 @@ const SlowBuffer = require('buffer').SlowBuffer; const util = require('util'); const pathModule = require('path'); -const binding = process.binding('fs'); +const binding = require('binding/fs'); const constants = require('constants'); const fs = exports; const Buffer = require('buffer').Buffer; const Stream = require('stream').Stream; const EventEmitter = require('events'); const FSReqWrap = binding.FSReqWrap; -const FSEvent = process.binding('fs_event_wrap').FSEvent; +const FSEvent = require('binding/fs_event_wrap').FSEvent; const Readable = Stream.Readable; const Writable = Stream.Writable; diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 8c1abc5f746fc8..a2c36efa5c4e58 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -9,13 +9,13 @@ const util = require('util'); const constants = require('constants'); const assert = require('assert'); -const Process = process.binding('process_wrap').Process; -const WriteWrap = process.binding('stream_wrap').WriteWrap; -const uv = process.binding('uv'); -const Pipe = process.binding('pipe_wrap').Pipe; -const TTY = process.binding('tty_wrap').TTY; -const TCP = process.binding('tcp_wrap').TCP; -const UDP = process.binding('udp_wrap').UDP; +const Process = require('binding/process_wrap').Process; +const WriteWrap = require('binding/stream_wrap').WriteWrap; +const uv = require('binding/uv'); +const Pipe = require('binding/pipe_wrap').Pipe; +const TTY = require('binding/tty_wrap').TTY; +const TCP = require('binding/tcp_wrap').TCP; +const UDP = require('binding/udp_wrap').UDP; const SocketList = require('internal/socket_list'); const errnoException = util._errnoException; diff --git a/lib/module.js b/lib/module.js index ef0fad209ff9c8..c0ccfade640e0a 100644 --- a/lib/module.js +++ b/lib/module.js @@ -8,8 +8,8 @@ const runInThisContext = require('vm').runInThisContext; const assert = require('assert').ok; const fs = require('fs'); const path = require('path'); -const internalModuleReadFile = process.binding('fs').internalModuleReadFile; -const internalModuleStat = process.binding('fs').internalModuleStat; +const internalModuleReadFile = require('binding/fs').internalModuleReadFile; +const internalModuleStat = require('binding/fs').internalModuleStat; // If obj.hasOwnProperty has been overridden, then calling diff --git a/lib/net.js b/lib/net.js index a7a8eb1fcc21a7..e9afd1d19f877d 100644 --- a/lib/net.js +++ b/lib/net.js @@ -6,17 +6,17 @@ const timers = require('timers'); const util = require('util'); const internalUtil = require('internal/util'); const assert = require('assert'); -const cares = process.binding('cares_wrap'); -const uv = process.binding('uv'); +const cares = require('binding/cares_wrap'); +const uv = require('binding/uv'); const Buffer = require('buffer').Buffer; -const TTYWrap = process.binding('tty_wrap'); -const TCP = process.binding('tcp_wrap').TCP; -const Pipe = process.binding('pipe_wrap').Pipe; -const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; -const PipeConnectWrap = process.binding('pipe_wrap').PipeConnectWrap; -const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; -const WriteWrap = process.binding('stream_wrap').WriteWrap; +const TTYWrap = require('binding/tty_wrap'); +const TCP = require('binding/tcp_wrap').TCP; +const Pipe = require('binding/pipe_wrap').Pipe; +const TCPConnectWrap = require('binding/tcp_wrap').TCPConnectWrap; +const PipeConnectWrap = require('binding/pipe_wrap').PipeConnectWrap; +const ShutdownWrap = require('binding/stream_wrap').ShutdownWrap; +const WriteWrap = require('binding/stream_wrap').WriteWrap; var cluster; diff --git a/lib/os.js b/lib/os.js index 2d537f53840a35..6ef939200afa6b 100644 --- a/lib/os.js +++ b/lib/os.js @@ -1,6 +1,6 @@ 'use strict'; -const binding = process.binding('os'); +const binding = require('binding/os'); const util = require('util'); const internalUtil = require('internal/util'); const isWindows = process.platform === 'win32'; diff --git a/lib/timers.js b/lib/timers.js index 50ae477d59d30f..6ae8ff21970cbe 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -1,6 +1,6 @@ 'use strict'; -const Timer = process.binding('timer_wrap').Timer; +const Timer = require('binding/timer_wrap').Timer; const L = require('internal/linkedlist'); const assert = require('assert').ok; const util = require('util'); diff --git a/lib/tls.js b/lib/tls.js index 0d85a948dcc511..9fca359ea82cc0 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -3,7 +3,7 @@ const net = require('net'); const url = require('url'); const util = require('util'); -const binding = process.binding('crypto'); +const binding = require('binding/crypto'); const Buffer = require('buffer').Buffer; const constants = require('constants'); diff --git a/lib/tty.js b/lib/tty.js index f3f84ca5a6e9f7..b4494c7160a41d 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -3,8 +3,8 @@ const util = require('util'); const internalUtil = require('internal/util'); const net = require('net'); -const TTY = process.binding('tty_wrap').TTY; -const isTTY = process.binding('tty_wrap').isTTY; +const TTY = require('binding/tty_wrap').TTY; +const isTTY = require('binding/tty_wrap').isTTY; const inherits = util.inherits; const errnoException = util._errnoException; diff --git a/lib/util.js b/lib/util.js index 399a4ee0a23828..508c818eb03506 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,9 +1,9 @@ 'use strict'; -const uv = process.binding('uv'); +const uv = require('binding/uv'); const Buffer = require('buffer').Buffer; const internalUtil = require('internal/util'); -const binding = process.binding('util'); +const binding = require('binding/util'); var Debug; diff --git a/lib/v8.js b/lib/v8.js index acadfa64e0650e..43d9606ac9bc92 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -14,7 +14,7 @@ 'use strict'; -const v8binding = process.binding('v8'); +const v8binding = require('binding/v8'); const heapStatisticsBuffer = new Uint32Array(v8binding.heapStatisticsArrayBuffer); diff --git a/lib/vm.js b/lib/vm.js index b4a2b9999091d2..51a4cfc119dc23 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -1,6 +1,6 @@ 'use strict'; -const binding = process.binding('contextify'); +const binding = require('binding/contextify'); const Script = binding.ContextifyScript; // The binding provides a few useful primitives: diff --git a/lib/zlib.js b/lib/zlib.js index a10d9118d6194e..c85728ee334d6e 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -2,7 +2,7 @@ const Buffer = require('buffer').Buffer; const Transform = require('_stream_transform'); -const binding = process.binding('zlib'); +const binding = require('binding/zlib'); const util = require('util'); const assert = require('assert').ok; const kMaxLength = require('buffer').kMaxLength; diff --git a/src/node.cc b/src/node.cc index 1dfa854ed5bb99..bfb3534fd91b13 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2976,7 +2976,6 @@ void SetupProcessObject(Environment* env, env->SetMethod(process, "uptime", Uptime); env->SetMethod(process, "memoryUsage", MemoryUsage); - env->SetMethod(process, "binding", Binding); env->SetMethod(process, "_linkedBinding", LinkedBinding); env->SetMethod(process, "_setupNextTick", SetupNextTick); @@ -3084,8 +3083,9 @@ void LoadEnvironment(Environment* env) { env->SetMethod(env->process_object(), "_rawDebug", RawDebug); - Local arg = env->process_object(); - f->Call(global, 1, &arg); + Local binding = env->NewFunctionTemplate(Binding)->GetFunction(); + Local args[] = { env->process_object(), binding }; + f->Call(global, ARRAY_SIZE(args), args); } static void PrintHelp(); diff --git a/src/node.js b/src/node.js index 7cfd2c035962a6..10500f803280ce 100644 --- a/src/node.js +++ b/src/node.js @@ -7,11 +7,13 @@ 'use strict'; -(function(process) { +(function(process, getBinding) { this.global = this; function startup() { var EventEmitter = NativeModule.require('events'); + process.binding = NativeModule.require('internal/util') + .deprecate(getBinding, 'process.binding is deprecated'); process.__proto__ = Object.create(EventEmitter.prototype, { constructor: { @@ -204,7 +206,7 @@ startup.lazyConstants = function() { if (!startup._lazyConstants) { - startup._lazyConstants = process.binding('constants'); + startup._lazyConstants = getBinding('constants'); } return startup._lazyConstants; }; @@ -580,7 +582,7 @@ function createWritableStdioStream(fd) { var stream; - var tty_wrap = process.binding('tty_wrap'); + var tty_wrap = getBinding('tty_wrap'); // Note stream._type is used for test-module-load-list.js @@ -657,7 +659,7 @@ process.__defineGetter__('stdin', function() { if (stdin) return stdin; - var tty_wrap = process.binding('tty_wrap'); + var tty_wrap = getBinding('tty_wrap'); var fd = 0; switch (tty_wrap.guessHandleType(fd)) { @@ -792,7 +794,7 @@ process.on('newListener', function(type, listener) { if (isSignal(type) && !signalWraps.hasOwnProperty(type)) { - var Signal = process.binding('signal_wrap').Signal; + var Signal = getBinding('signal_wrap').Signal; var wrap = new Signal(); wrap.unref(); @@ -835,7 +837,7 @@ // Load tcp_wrap to avoid situation where we might immediately receive // a message. // FIXME is this really necessary? - process.binding('tcp_wrap'); + getBinding('tcp_wrap'); cp._forkChild(fd); assert(process.send); @@ -862,7 +864,7 @@ // core modules found in lib/*.js. All core modules are compiled into the // node binary, so they can be loaded faster. - var ContextifyScript = process.binding('contextify').ContextifyScript; + var ContextifyScript = getBinding('contextify').ContextifyScript; function runInThisContext(code, options) { var script = new ContextifyScript(code, options); return script.runInThisContext(); @@ -875,7 +877,7 @@ this.loaded = false; } - NativeModule._source = process.binding('natives'); + NativeModule._source = getBinding('natives'); NativeModule._cache = {}; NativeModule.require = function(id) { @@ -883,6 +885,10 @@ return NativeModule; } + if (id.startsWith('binding/')) { + return getBinding(id.slice(8)); + } + var cached = NativeModule.getCached(id); if (cached) { return cached.exports; @@ -907,7 +913,7 @@ }; NativeModule.exists = function(id) { - return NativeModule._source.hasOwnProperty(id); + return NativeModule._source.hasOwnProperty(id) || id.startsWith('binding/'); }; const EXPOSE_INTERNALS = process.execArgv.some(function(arg) { @@ -926,7 +932,7 @@ }; NativeModule.isInternal = function(id) { - return id.startsWith('internal/'); + return id.startsWith('internal/') || id.startsWith('binding/'); }; } diff --git a/test/common.js b/test/common.js index b4aa4edaf3dca0..1af7b49e5ac412 100644 --- a/test/common.js +++ b/test/common.js @@ -422,7 +422,7 @@ exports.getServiceName = function getServiceName(port, protocol) { }; exports.hasMultiLocalhost = function hasMultiLocalhost() { - var TCP = process.binding('tcp_wrap').TCP; + var TCP = require('binding/tcp_wrap').TCP; var t = new TCP(); var ret = t.bind('127.0.0.2', exports.PORT); t.close(); diff --git a/test/disabled/test-sendfd.js b/test/disabled/test-sendfd.js index b48acadba51768..e2dd6c3790e962 100644 --- a/test/disabled/test-sendfd.js +++ b/test/disabled/test-sendfd.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --expose_internals // Test sending and receiving a file descriptor. // // This test is pretty complex. It ends up spawning test/fixtures/recvfd.js @@ -33,7 +34,7 @@ var buffer = require('buffer'); var child_process = require('child_process'); var fs = require('fs'); var net = require('net'); -var netBinding = process.binding('net'); +var netBinding = require('binding/net'); var path = require('path'); var DATA = { diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index 2a423f97dee7b0..4cd97aeca3d210 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'), dns = require('dns'), @@ -367,7 +368,7 @@ var getaddrinfoCallbackCalled = false; console.log('looking up nodejs.org...'); -var cares = process.binding('cares_wrap'); +var cares = require('binding/cares_wrap'); var req = new cares.GetAddrInfoReqWrap(); var err = cares.getaddrinfo(req, 'nodejs.org', 4); diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index 2d7d318885eb16..ab9ec5d729ee36 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -1,5 +1,5 @@ 'use strict'; - +// Flags: --expose_internals const common = require('../common'); const assert = require('assert'); const crypto = require('crypto'); @@ -11,7 +11,7 @@ const tls = require('tls'); const zlib = require('zlib'); const ChildProcess = require('child_process').ChildProcess; const StreamWrap = require('_stream_wrap').StreamWrap; -const async_wrap = process.binding('async_wrap'); +const async_wrap = require('binding/async_wrap'); const pkeys = Object.keys(async_wrap.Providers); let keyList = pkeys.slice(); @@ -43,7 +43,7 @@ dns.resolve('localhost', noop); new StreamWrap(new net.Socket()); -new (process.binding('tty_wrap').TTY)(); +new (require('binding/tty_wrap').TTY)(); crypto.randomBytes(1, noop); diff --git a/test/parallel/test-async-wrap-disabled-propagate-parent.js b/test/parallel/test-async-wrap-disabled-propagate-parent.js index de36071524c4fe..633bc2f51a9310 100644 --- a/test/parallel/test-async-wrap-disabled-propagate-parent.js +++ b/test/parallel/test-async-wrap-disabled-propagate-parent.js @@ -1,9 +1,9 @@ 'use strict'; - +// Flags: --expose_internals const common = require('../common'); const assert = require('assert'); const net = require('net'); -const async_wrap = process.binding('async_wrap'); +const async_wrap = require('binding/async_wrap'); const providers = Object.keys(async_wrap.Providers); let cntr = 0; diff --git a/test/parallel/test-async-wrap-propagate-parent.js b/test/parallel/test-async-wrap-propagate-parent.js index 8074b0062e0db2..c930cbd4d8285a 100644 --- a/test/parallel/test-async-wrap-propagate-parent.js +++ b/test/parallel/test-async-wrap-propagate-parent.js @@ -1,9 +1,9 @@ 'use strict'; - +// Flags: --expose_internals const common = require('../common'); const assert = require('assert'); const net = require('net'); -const async_wrap = process.binding('async_wrap'); +const async_wrap = require('binding/async_wrap'); let cntr = 0; let server; diff --git a/test/parallel/test-dns-lookup-cb-error.js b/test/parallel/test-dns-lookup-cb-error.js index 330dfb5d57092a..0e6ad7ad608d77 100644 --- a/test/parallel/test-dns-lookup-cb-error.js +++ b/test/parallel/test-dns-lookup-cb-error.js @@ -1,13 +1,14 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var cares = process.binding('cares_wrap'); +var cares = require('binding/cares_wrap'); var dns = require('dns'); // Stub `getaddrinfo` to *always* error. cares.getaddrinfo = function() { - return process.binding('uv').UV_ENOENT; + return require('binding/uv').UV_ENOENT; }; assert.doesNotThrow(function() { diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index ac5de820263787..2037b887466382 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var http = require('http'), assert = require('assert'); diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index d409dc62d008d9..a1186b8141ad65 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -2,11 +2,11 @@ // Run this program with valgrind or efence with --expose_gc to expose the // problem. -// Flags: --expose_gc +// Flags: --expose_gc --expose_internals var common = require('../common'); var assert = require('assert'); -var HTTPParser = process.binding('http_parser').HTTPParser; +var HTTPParser = require('binding/http_parser').HTTPParser; var kOnHeaders = HTTPParser.kOnHeaders | 0; var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index bb004f864cf468..a9e7f543c5803b 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -1,8 +1,9 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var HTTPParser = process.binding('http_parser').HTTPParser; +var HTTPParser = require('binding/http_parser').HTTPParser; var CRLF = '\r\n'; var REQUEST = HTTPParser.REQUEST; diff --git a/test/parallel/test-http-regr-gh-2928.js b/test/parallel/test-http-regr-gh-2928.js index 92cfd9ca356d46..84b3a1a6bab8be 100644 --- a/test/parallel/test-http-regr-gh-2928.js +++ b/test/parallel/test-http-regr-gh-2928.js @@ -1,8 +1,9 @@ 'use strict'; +// Flags: --expose_internals const common = require('../common'); const assert = require('assert'); const httpCommon = require('_http_common'); -const HTTPParser = process.binding('http_parser').HTTPParser; +const HTTPParser = require('binding/http_parser').HTTPParser; const net = require('net'); const PARALLEL = 30; diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index a330c4881a9e47..aeeaf9ec117156 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'), fs = require('fs'), assert = require('assert'); diff --git a/test/parallel/test-js-stream-call-properties.js b/test/parallel/test-js-stream-call-properties.js index c6b1adb3cb7a7a..325f5420a1499a 100644 --- a/test/parallel/test-js-stream-call-properties.js +++ b/test/parallel/test-js-stream-call-properties.js @@ -1,8 +1,8 @@ 'use strict'; - +// Flags: --expose_internals const common = require('../common'); const util = require('util'); -const JSStream = process.binding('js_stream').JSStream; +const JSStream = require('binding/js_stream').JSStream; // Testing if will abort when properties are printed. util.inspect(new JSStream()); diff --git a/test/parallel/test-net-persistent-nodelay.js b/test/parallel/test-net-persistent-nodelay.js index e120305b3a62eb..6de583655523e6 100644 --- a/test/parallel/test-net-persistent-nodelay.js +++ b/test/parallel/test-net-persistent-nodelay.js @@ -1,8 +1,9 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); var net = require('net'); -var TCPWrap = process.binding('tcp_wrap').TCP; +var TCPWrap = require('binding/tcp_wrap').TCP; var echoServer = net.createServer(function(connection) { connection.end(); diff --git a/test/parallel/test-net-persistent-ref-unref.js b/test/parallel/test-net-persistent-ref-unref.js index b3ea0969f39961..929d0cb94e3a83 100644 --- a/test/parallel/test-net-persistent-ref-unref.js +++ b/test/parallel/test-net-persistent-ref-unref.js @@ -1,8 +1,9 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); var net = require('net'); -var TCPWrap = process.binding('tcp_wrap').TCP; +var TCPWrap = require('binding/tcp_wrap').TCP; var echoServer = net.createServer(function(conn) { conn.end(); diff --git a/test/parallel/test-process-binding.js b/test/parallel/test-process-binding.js index 5350a8c66932cb..3f9b3159f8ca8c 100644 --- a/test/parallel/test-process-binding.js +++ b/test/parallel/test-process-binding.js @@ -1,16 +1,17 @@ 'use strict'; +// Flags: --expose_internals require('../common'); var assert = require('assert'); assert.throws( function() { - process.binding('test'); + require('binding/test'); }, /No such module: test/ ); assert.doesNotThrow(function() { - process.binding('buffer'); + require('binding/buffer'); }, function(err) { if ( (err instanceof Error) ) { return true; diff --git a/test/parallel/test-process-wrap.js b/test/parallel/test-process-wrap.js index bf3dfe4e8b1651..70bd278486a0cb 100644 --- a/test/parallel/test-process-wrap.js +++ b/test/parallel/test-process-wrap.js @@ -1,8 +1,9 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var Process = process.binding('process_wrap').Process; -var Pipe = process.binding('pipe_wrap').Pipe; +var Process = require('binding/process_wrap').Process; +var Pipe = require('binding/pipe_wrap').Pipe; var pipe = new Pipe(); var p = new Process(); diff --git a/test/parallel/test-signal-safety.js b/test/parallel/test-signal-safety.js index 549c26662f717a..8f9b6d26819cdc 100644 --- a/test/parallel/test-signal-safety.js +++ b/test/parallel/test-signal-safety.js @@ -1,7 +1,8 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var Signal = process.binding('signal_wrap').Signal; +var Signal = require('binding/signal_wrap').Signal; // Test Signal `this` safety // https://github.com/joyent/node/issues/6690 diff --git a/test/parallel/test-stream-wrap.js b/test/parallel/test-stream-wrap.js index e7a7ecddd2385d..2261ec1b1964d4 100644 --- a/test/parallel/test-stream-wrap.js +++ b/test/parallel/test-stream-wrap.js @@ -1,10 +1,11 @@ 'use strict'; +// Flags: --expose_internals const common = require('../common'); const assert = require('assert'); const StreamWrap = require('_stream_wrap'); const Duplex = require('stream').Duplex; -const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; +const ShutdownWrap = require('binding/stream_wrap').ShutdownWrap; var done = false; diff --git a/test/parallel/test-stringbytes-external-at-max.js b/test/parallel/test-stringbytes-external-at-max.js index 6678e5355224b3..7723ee391c06f6 100644 --- a/test/parallel/test-stringbytes-external-at-max.js +++ b/test/parallel/test-stringbytes-external-at-max.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js index e982cf9eb092fd..a55aefc80d0131 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-ascii.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js index 43a3358759e249..3103bae6f33a4a 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-base64.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js index 9d0d2c3e897057..7bb41595742309 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-binary.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js index 2937b4aab85813..f4e1c54ae5df63 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-hex.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js index ee297a880dacbd..ffe6a5994dc373 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-1-utf8.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max-by-2.js b/test/parallel/test-stringbytes-external-exceed-max-by-2.js index 879e4ae91dfb60..efa307d8df301a 100644 --- a/test/parallel/test-stringbytes-external-exceed-max-by-2.js +++ b/test/parallel/test-stringbytes-external-exceed-max-by-2.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external-exceed-max.js b/test/parallel/test-stringbytes-external-exceed-max.js index 0a6f585b66f3ad..8ee378429caeb4 100644 --- a/test/parallel/test-stringbytes-external-exceed-max.js +++ b/test/parallel/test-stringbytes-external-exceed-max.js @@ -1,11 +1,11 @@ 'use strict'; - +// Flags: --expose_internals require('../common'); const assert = require('assert'); // v8 fails silently if string length > v8::String::kMaxLength // v8::String::kMaxLength defined in v8.h -const kStringMaxLength = process.binding('buffer').kStringMaxLength; +const kStringMaxLength = require('binding/buffer').kStringMaxLength; try { new Buffer(kStringMaxLength * 3); diff --git a/test/parallel/test-stringbytes-external.js b/test/parallel/test-stringbytes-external.js index ba3f0c5d1d9ade..fc86fc6c03cbed 100644 --- a/test/parallel/test-stringbytes-external.js +++ b/test/parallel/test-stringbytes-external.js @@ -1,4 +1,5 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); // minimum string size to overflow into external string space diff --git a/test/parallel/test-tcp-wrap.js b/test/parallel/test-tcp-wrap.js index 93da3e5b3b41c8..110fcbb4944258 100644 --- a/test/parallel/test-tcp-wrap.js +++ b/test/parallel/test-tcp-wrap.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var TCP = process.binding('tcp_wrap').TCP; -var uv = process.binding('uv'); +var TCP = require('binding/tcp_wrap').TCP; +var uv = require('binding/uv'); var handle = new TCP(); diff --git a/test/parallel/test-timer-close.js b/test/parallel/test-timer-close.js index 9eb70041eb4b97..8b855029e9c6df 100644 --- a/test/parallel/test-timer-close.js +++ b/test/parallel/test-timer-close.js @@ -1,8 +1,9 @@ 'use strict'; +// Flags: --expose_internals require('../common'); var assert = require('assert'); -var t = new (process.binding('timer_wrap').Timer); +var t = new (require('binding/timer_wrap').Timer); var called = 0; function onclose() { called++; diff --git a/test/parallel/test-timers-now.js b/test/parallel/test-timers-now.js index 466bd064b8decf..a85264aaa23679 100644 --- a/test/parallel/test-timers-now.js +++ b/test/parallel/test-timers-now.js @@ -1,8 +1,8 @@ 'use strict'; - +// Flags: --expose_internals const common = require('../common'); const assert = require('assert'); // Return value of Timer.now() should easily fit in a SMI right after start-up. -const Timer = process.binding('timer_wrap').Timer; +const Timer = require('binding/timer_wrap').Timer; assert(Timer.now() < 0x3ffffff); diff --git a/test/parallel/test-timers-ordering.js b/test/parallel/test-timers-ordering.js index 730a78a072c663..386316836e1910 100644 --- a/test/parallel/test-timers-ordering.js +++ b/test/parallel/test-timers-ordering.js @@ -1,7 +1,8 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var Timer = process.binding('timer_wrap').Timer; +var Timer = require('binding/timer_wrap').Timer; var i; diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js index b348330d200d65..4c2b465a4a4bd5 100644 --- a/test/parallel/test-timers-unref-call.js +++ b/test/parallel/test-timers-unref-call.js @@ -1,7 +1,8 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); -var Timer = process.binding('timer_wrap').Timer; +var Timer = require('binding/timer_wrap').Timer; Timer.now = function() { return ++Timer.now.ticks; }; Timer.now.ticks = 0; diff --git a/test/parallel/test-tty-wrap.js b/test/parallel/test-tty-wrap.js index dbe7b6890fd218..69393dcc03f94e 100644 --- a/test/parallel/test-tty-wrap.js +++ b/test/parallel/test-tty-wrap.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var TTY = process.binding('tty_wrap').TTY; -var isTTY = process.binding('tty_wrap').isTTY; +var TTY = require('binding/tty_wrap').TTY; +var isTTY = require('binding/tty_wrap').isTTY; if (isTTY(1) == false) { console.log('1..0 # Skipped: fd 1 is not a tty.'); diff --git a/test/pummel/test-timer-wrap.js b/test/pummel/test-timer-wrap.js index 62ba69d3fde033..6b913534ca41f3 100644 --- a/test/pummel/test-timer-wrap.js +++ b/test/pummel/test-timer-wrap.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); var timeouts = 0; -var Timer = process.binding('timer_wrap').Timer; +var Timer = require('binding/timer_wrap').Timer; var kOnTimeout = Timer.kOnTimeout; var t = new Timer(); diff --git a/test/pummel/test-timer-wrap2.js b/test/pummel/test-timer-wrap2.js index b289a85644a068..c60af2d1852139 100644 --- a/test/pummel/test-timer-wrap2.js +++ b/test/pummel/test-timer-wrap2.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); // Test that allocating a timer does not increase the loop's reference // count. -var Timer = process.binding('timer_wrap').Timer; +var Timer = require('binding/timer_wrap').Timer; var t = new Timer(); diff --git a/test/sequential/test-tcp-wrap-connect.js b/test/sequential/test-tcp-wrap-connect.js index 9373906c6f612a..e381a553ff8ca9 100644 --- a/test/sequential/test-tcp-wrap-connect.js +++ b/test/sequential/test-tcp-wrap-connect.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var TCP = process.binding('tcp_wrap').TCP; -var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; -var ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; +var TCP = require('binding/tcp_wrap').TCP; +var TCPConnectWrap = require('binding/tcp_wrap').TCPConnectWrap; +var ShutdownWrap = require('binding/stream_wrap').ShutdownWrap; function makeConnection() { var client = new TCP(); diff --git a/test/sequential/test-tcp-wrap-listen.js b/test/sequential/test-tcp-wrap-listen.js index a2c07a7a9ce2a2..108656f445f3d5 100644 --- a/test/sequential/test-tcp-wrap-listen.js +++ b/test/sequential/test-tcp-wrap-listen.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals var common = require('../common'); var assert = require('assert'); -var TCP = process.binding('tcp_wrap').TCP; -var WriteWrap = process.binding('stream_wrap').WriteWrap; +var TCP = require('binding/tcp_wrap').TCP; +var WriteWrap = require('binding/stream_wrap').WriteWrap; var server = new TCP(); diff --git a/test/timers/test-timers-reliability.js b/test/timers/test-timers-reliability.js index b4332468bc2ec3..751cd86dc13b53 100644 --- a/test/timers/test-timers-reliability.js +++ b/test/timers/test-timers-reliability.js @@ -1,9 +1,10 @@ 'use strict'; +// Flags: --expose_internals // FaketimeFlags: --exclude-monotonic -f '2014-07-21 09:00:00' var common = require('../common'); -var Timer = process.binding('timer_wrap').Timer; +var Timer = require('binding/timer_wrap').Timer; var assert = require('assert'); var timerFired = false;