11cb0ef41Sopenharmony_ci// Flags: --require ./test/fixtures/overwrite-config-preload-module.js 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ci// This test ensures that overwriting a process configuration 51cb0ef41Sopenharmony_ci// value does not affect code in lib/internal/bootstrap/node.js. 61cb0ef41Sopenharmony_ci// Specifically this tests 71cb0ef41Sopenharmony_ci// that the inspector console functions are bound even though 81cb0ef41Sopenharmony_ci// overwrite-config-preload-module.js overwrote the process.config variable. 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci// We cannot do a check for the inspector because the configuration variables 111cb0ef41Sopenharmony_ci// were reset/removed by overwrite-config-preload-module.js. 121cb0ef41Sopenharmony_ci/* eslint-disable node-core/inspector-check */ 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst common = require('../common'); 151cb0ef41Sopenharmony_ciconst assert = require('assert'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciif (!common.isMainThread) 181cb0ef41Sopenharmony_ci common.skip('--require does not work with Workers'); 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciconst inspector = require('inspector'); 211cb0ef41Sopenharmony_ciconst msg = 'Test inspector logging'; 221cb0ef41Sopenharmony_cilet asserted = false; 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciasync function testConsoleLog() { 251cb0ef41Sopenharmony_ci const session = new inspector.Session(); 261cb0ef41Sopenharmony_ci session.connect(); 271cb0ef41Sopenharmony_ci session.on('inspectorNotification', (data) => { 281cb0ef41Sopenharmony_ci if (data.method === 'Runtime.consoleAPICalled') { 291cb0ef41Sopenharmony_ci assert.strictEqual(data.params.args.length, 1); 301cb0ef41Sopenharmony_ci assert.strictEqual(data.params.args[0].value, msg); 311cb0ef41Sopenharmony_ci asserted = true; 321cb0ef41Sopenharmony_ci } 331cb0ef41Sopenharmony_ci }); 341cb0ef41Sopenharmony_ci session.post('Runtime.enable'); 351cb0ef41Sopenharmony_ci console.log(msg); 361cb0ef41Sopenharmony_ci session.disconnect(); 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ciasync function runTests() { 401cb0ef41Sopenharmony_ci await testConsoleLog(); 411cb0ef41Sopenharmony_ci assert.ok(asserted, 'log statement did not reach the inspector'); 421cb0ef41Sopenharmony_ci} 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_cirunTests().then(common.mustCall()); 45