diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-03-04 04:55:45 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-03-06 22:12:46 +0800 |
commit | 2a9eb316a1e86d8b191aa2cdfd25d45508456573 (patch) | |
tree | 743074a353fc55583bbec14e4d56a27ea0911bc8 /test/parallel/test-loaders-hidden-from-users.js | |
parent | 1a5ec837ca56774f2a9ee54ee9a0f6cbfa01d4bc (diff) | |
download | android-node-v8-2a9eb316a1e86d8b191aa2cdfd25d45508456573.tar.gz android-node-v8-2a9eb316a1e86d8b191aa2cdfd25d45508456573.tar.bz2 android-node-v8-2a9eb316a1e86d8b191aa2cdfd25d45508456573.zip |
src: move internal loaders out of bootstrap_node.js
- Moves the creation of `process.binding()`, `process._linkedBinding()`
`internalBinding()` and `NativeModule` into a separate file
`lib/internal/bootstrap_loaders.js`, and documents them there.
This file will be compiled and run before `bootstrap_node.js`, which
means we now bootstrap the internal module & binding system before
actually bootstrapping Node.js.
- Rename the special ID that can be used to require `NativeModule`
as `internal/bootstrap_loaders` since it is setup there. Also put
`internalBinding` in the object exported by `NativeModule.require`
instead of putting it inside the `NativeModule.wrapper`
- Use the original `getBinding()` to get the source code of native
modules instead of getting it from `process.binding('native')`
so that users cannot fake native modules by modifying the binding
object.
- Names the bootstrapping functions so their names show up
in the stack trace.
PR-URL: https://github.com/nodejs/node/pull/19112
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'test/parallel/test-loaders-hidden-from-users.js')
-rw-r--r-- | test/parallel/test-loaders-hidden-from-users.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-loaders-hidden-from-users.js b/test/parallel/test-loaders-hidden-from-users.js new file mode 100644 index 0000000000..b3e6622c8c --- /dev/null +++ b/test/parallel/test-loaders-hidden-from-users.js @@ -0,0 +1,25 @@ +// Flags: --expose-internals + +'use strict'; + +const common = require('../common'); + +common.expectsError( + () => { + require('internal/bootstrap_loaders'); + }, { + code: 'MODULE_NOT_FOUND', + message: 'Cannot find module \'internal/bootstrap_loaders\'' + } +); + +common.expectsError( + () => { + const source = 'module.exports = require("internal/bootstrap_loaders")'; + process.binding('natives').owo = source; + require('owo'); + }, { + code: 'MODULE_NOT_FOUND', + message: 'Cannot find module \'owo\'' + } +); |