From 732e5023be49856e09ffa45f80e629e361928fbe Mon Sep 17 00:00:00 2001 From: Anto Aravinth Date: Tue, 4 Sep 2018 19:43:25 +0530 Subject: [PATCH] js_stream: move process.binding('js_stream') to internalBinding --- lib/internal/bootstrap/node.js | 3 ++- lib/internal/wrap_js_stream.js | 2 +- src/js_stream.cc | 2 +- test/parallel/test-js-stream-call-properties.js | 5 ++++- .../test-process-binding-internalbinding-whitelist.js | 1 + test/parallel/test-util-inspect.js | 3 ++- test/parallel/test-util-types.js | 5 +++-- test/parallel/test-v8-serdes.js | 5 ++++- test/sequential/test-async-wrap-getasyncid.js | 2 +- 9 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 418c93f0d5ac4e..6e42311f391d92 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -377,7 +377,8 @@ 'util', 'async_wrap', 'url', - 'spawn_sync']); + 'spawn_sync', + 'js_stream']); process.binding = function binding(name) { return internalBindingWhitelist.has(name) ? internalBinding(name) : diff --git a/lib/internal/wrap_js_stream.js b/lib/internal/wrap_js_stream.js index 5ffdd23a7db3bf..3c75bd9163fccf 100644 --- a/lib/internal/wrap_js_stream.js +++ b/lib/internal/wrap_js_stream.js @@ -3,8 +3,8 @@ const assert = require('assert'); const util = require('util'); const { Socket } = require('net'); -const { JSStream } = process.binding('js_stream'); const { internalBinding } = require('internal/bootstrap/loaders'); +const { JSStream } = internalBinding('js_stream'); const uv = internalBinding('uv'); const debug = util.debuglog('stream_wrap'); const { owner_symbol } = require('internal/async_hooks').symbols; diff --git a/src/js_stream.cc b/src/js_stream.cc index 4769a9c56d633f..c7e169b4652615 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -216,4 +216,4 @@ void JSStream::Initialize(Local target, } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(js_stream, node::JSStream::Initialize) +NODE_MODULE_CONTEXT_AWARE_INTERNAL(js_stream, node::JSStream::Initialize) diff --git a/test/parallel/test-js-stream-call-properties.js b/test/parallel/test-js-stream-call-properties.js index 280e5d9dabee66..c001fbdb136726 100644 --- a/test/parallel/test-js-stream-call-properties.js +++ b/test/parallel/test-js-stream-call-properties.js @@ -1,8 +1,11 @@ +// Flags: --expose-internals + 'use strict'; require('../common'); const util = require('util'); -const JSStream = process.binding('js_stream').JSStream; +const { internalBinding } = require('internal/test/binding'); +const { JSStream } = internalBinding('js_stream'); // Testing if will abort when properties are printed. util.inspect(new JSStream()); diff --git a/test/parallel/test-process-binding-internalbinding-whitelist.js b/test/parallel/test-process-binding-internalbinding-whitelist.js index 7076650e1bce78..56715799f88506 100644 --- a/test/parallel/test-process-binding-internalbinding-whitelist.js +++ b/test/parallel/test-process-binding-internalbinding-whitelist.js @@ -14,3 +14,4 @@ assert(process.binding('signal_wrap')); assert(process.binding('contextify')); assert(process.binding('url')); assert(process.binding('spawn_sync')); +assert(process.binding('js_stream')); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 4cd7286f1f4eb9..467849cf7a8012 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -20,11 +20,12 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +// Flags: --expose-internals 'use strict'; const common = require('../common'); const assert = require('assert'); const { internalBinding } = require('internal/test/binding'); -const JSStream = process.binding('js_stream').JSStream; +const { JSStream } = internalBinding('js_stream'); const util = require('util'); const vm = require('vm'); const { previewEntries } = internalBinding('util'); diff --git a/test/parallel/test-util-types.js b/test/parallel/test-util-types.js index 2978cbf98deb0c..64434e574a2de3 100644 --- a/test/parallel/test-util-types.js +++ b/test/parallel/test-util-types.js @@ -1,11 +1,12 @@ -// Flags: --experimental-vm-modules +// Flags: --experimental-vm-modules --expose-internals 'use strict'; require('../common'); const fixtures = require('../common/fixtures'); const assert = require('assert'); const { types, inspect } = require('util'); const vm = require('vm'); -const { JSStream } = process.binding('js_stream'); +const { internalBinding } = require('internal/test/binding'); +const { JSStream } = internalBinding('js_stream'); const external = (new JSStream())._externalStream; const wasmBuffer = fixtures.readSync('test.wasm'); diff --git a/test/parallel/test-v8-serdes.js b/test/parallel/test-v8-serdes.js index ad8666ee3ba877..94f10dbfe9fb09 100644 --- a/test/parallel/test-v8-serdes.js +++ b/test/parallel/test-v8-serdes.js @@ -1,5 +1,8 @@ +// Flags: --expose-gc --expose-internals + 'use strict'; +const { internalBinding } = require('internal/test/binding'); const common = require('../common'); const assert = require('assert'); const v8 = require('v8'); @@ -20,7 +23,7 @@ const objects = [ circular ]; -const hostObject = new (process.binding('js_stream').JSStream)(); +const hostObject = new (internalBinding('js_stream').JSStream)(); const serializerTypeError = /^TypeError: Class constructor Serializer cannot be invoked without 'new'$/; diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index aac356df2a00ed..148e4da3006e97 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -94,7 +94,7 @@ function testInitialized(req, ctor_name) { { - const JSStream = process.binding('js_stream').JSStream; + const JSStream = internalBinding('js_stream').JSStream; testInitialized(new JSStream(), 'JSStream'); }