From 4963a04b304e5417f5ba8f769ae8040c18fd018d Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 20 Aug 2018 13:42:08 -0700 Subject: [PATCH] vm: move process.binding('contextify') to internalBinding PR-URL: https://github.com/nodejs/node/pull/22419 Refs: https://github.com/nodejs/node/issues/22160 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Refael Ackermann Reviewed-By: Anna Henningsen --- lib/internal/bootstrap/loaders.js | 2 +- lib/internal/bootstrap/node.js | 3 ++- lib/internal/vm/source_text_module.js | 2 +- lib/vm.js | 3 ++- src/node_contextify.cc | 2 +- .../parallel/test-process-binding-internalbinding-whitelist.js | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index c04a4207c0b482..5a28fdda10c529 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -107,7 +107,7 @@ }; } - const { ContextifyScript } = process.binding('contextify'); + const { ContextifyScript } = internalBinding('contextify'); // Set up NativeModule function NativeModule(id) { diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 6a4e4860b3ca84..2482b5d31b8fd5 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -351,7 +351,8 @@ 'v8', 'stream_wrap', 'signal_wrap', - 'crypto']); + 'crypto', + 'contextify']); process.binding = function binding(name) { return internalBindingWhitelist.has(name) ? internalBinding(name) : diff --git a/lib/internal/vm/source_text_module.js b/lib/internal/vm/source_text_module.js index bea7d7c94aea04..6bba7d782f4385 100644 --- a/lib/internal/vm/source_text_module.js +++ b/lib/internal/vm/source_text_module.js @@ -2,7 +2,7 @@ const { internalBinding } = require('internal/bootstrap/loaders'); const { URL } = require('internal/url'); -const { isContext } = process.binding('contextify'); +const { isContext } = internalBinding('contextify'); const { ERR_INVALID_ARG_TYPE, ERR_VM_MODULE_ALREADY_LINKED, diff --git a/lib/vm.js b/lib/vm.js index 3dd63fe2af1222..b80cd98dee1444 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -21,11 +21,12 @@ 'use strict'; +const { internalBinding } = require('internal/bootstrap/loaders'); const { ContextifyScript, makeContext, isContext: _isContext, -} = process.binding('contextify'); +} = internalBinding('contextify'); const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes; const { isUint8Array } = require('internal/util/types'); const { validateInt32, validateUint32 } = require('internal/validators'); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index be4c0e5cf303d7..a01fe88cea077a 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -958,4 +958,4 @@ void Initialize(Local target, } // namespace contextify } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(contextify, node::contextify::Initialize) +NODE_MODULE_CONTEXT_AWARE_INTERNAL(contextify, node::contextify::Initialize) diff --git a/test/parallel/test-process-binding-internalbinding-whitelist.js b/test/parallel/test-process-binding-internalbinding-whitelist.js index 5c74a29b735a47..63ce002887db8a 100644 --- a/test/parallel/test-process-binding-internalbinding-whitelist.js +++ b/test/parallel/test-process-binding-internalbinding-whitelist.js @@ -11,3 +11,4 @@ assert(process.binding('http_parser')); assert(process.binding('v8')); assert(process.binding('stream_wrap')); assert(process.binding('signal_wrap')); +assert(process.binding('contextify'));