|
| 1 | +// Flags: --require ./test/fixtures/overwrite-config-preload-module.js |
| 2 | +'use strict'; |
| 3 | + |
| 4 | +// This test ensures that overwriting a process configuration |
| 5 | +// value does not affect code in bootstrap_node.js. Specifically this tests |
| 6 | +// that the inspector console functions are bound even though |
| 7 | +// overwrite-config-preload-module.js overwrote the process.config variable. |
| 8 | + |
| 9 | +// We cannot do a check for the inspector because the configuration variables |
| 10 | +// were reset/removed by overwrite-config-preload-module.js. |
| 11 | +/* eslint-disable inspector-check */ |
| 12 | + |
| 13 | +const common = require('../common'); |
| 14 | +const assert = require('assert'); |
| 15 | +const inspector = require('inspector'); |
| 16 | +const msg = 'Test inspector logging'; |
| 17 | +let asserted = false; |
| 18 | + |
| 19 | +async function testConsoleLog() { |
| 20 | + const session = new inspector.Session(); |
| 21 | + session.connect(); |
| 22 | + session.on('inspectorNotification', (data) => { |
| 23 | + if (data.method === 'Runtime.consoleAPICalled') { |
| 24 | + assert.strictEqual(data.params.args.length, 1); |
| 25 | + assert.strictEqual(data.params.args[0].value, msg); |
| 26 | + asserted = true; |
| 27 | + } |
| 28 | + }); |
| 29 | + session.post('Runtime.enable'); |
| 30 | + console.log(msg); |
| 31 | + session.disconnect(); |
| 32 | +} |
| 33 | + |
| 34 | +common.crashOnUnhandledRejection(); |
| 35 | + |
| 36 | +async function runTests() { |
| 37 | + await testConsoleLog(); |
| 38 | + assert.ok(asserted, 'log statement did not reach the inspector'); |
| 39 | +} |
| 40 | + |
| 41 | +runTests(); |
0 commit comments