11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst { NodeInstance } = require('../common/inspector-helper.js'); 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciasync function runTest() { 101cb0ef41Sopenharmony_ci const script = 'require(\'inspector\').console.log(\'hello world\');'; 111cb0ef41Sopenharmony_ci const child = new NodeInstance('--inspect-brk=0', script, ''); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci let out = ''; 141cb0ef41Sopenharmony_ci child.on('stdout', (line) => out += line); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci const session = await child.connectInspectorSession(); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci const commands = [ 191cb0ef41Sopenharmony_ci { 'method': 'Runtime.enable' }, 201cb0ef41Sopenharmony_ci { 'method': 'Runtime.runIfWaitingForDebugger' }, 211cb0ef41Sopenharmony_ci ]; 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci session.send(commands); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci const msg = await session.waitForNotification('Runtime.consoleAPICalled'); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci assert.strictEqual(msg.params.type, 'log'); 281cb0ef41Sopenharmony_ci assert.deepStrictEqual(msg.params.args, [{ 291cb0ef41Sopenharmony_ci type: 'string', 301cb0ef41Sopenharmony_ci value: 'hello world' 311cb0ef41Sopenharmony_ci }]); 321cb0ef41Sopenharmony_ci assert.strictEqual(out, ''); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci session.disconnect(); 351cb0ef41Sopenharmony_ci} 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_cirunTest().then(common.mustCall()); 38