-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: guard inspector console using process var
Currently the inspector module is always loaded and if it does not return anything the inspector console setup is skipped. This commit uses the process.config.variables.v8_enable_inspector variable to only load the inspector module if it is enabled. PR-URL: #15008 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
85fd7bb
commit 14f8cee
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict' | ||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
process.config = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Flags: --require ./test/fixtures/overwrite-config-preload-module.js | ||
'use strict'; | ||
|
||
// This test ensures that overwriting a process configuration | ||
// value does not affect code in bootstrap_node.js. Specifically this tests | ||
// that the inspector console functions are bound even though | ||
// overwrite-config-preload-module.js overwrote the process.config variable. | ||
|
||
// We cannot do a check for the inspector because the configuration variables | ||
// were reset/removed by overwrite-config-preload-module.js. | ||
/* eslint-disable inspector-check */ | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const inspector = require('inspector'); | ||
const msg = 'Test inspector logging'; | ||
let asserted = false; | ||
|
||
async function testConsoleLog() { | ||
const session = new inspector.Session(); | ||
session.connect(); | ||
session.on('inspectorNotification', (data) => { | ||
if (data.method === 'Runtime.consoleAPICalled') { | ||
assert.strictEqual(data.params.args.length, 1); | ||
assert.strictEqual(data.params.args[0].value, msg); | ||
asserted = true; | ||
} | ||
}); | ||
session.post('Runtime.enable'); | ||
console.log(msg); | ||
session.disconnect(); | ||
} | ||
|
||
common.crashOnUnhandledRejection(); | ||
|
||
async function runTests() { | ||
await testConsoleLog(); | ||
assert.ok(asserted, 'log statement did not reach the inspector'); | ||
} | ||
|
||
runTests(); |