-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds require('inspector').console, mapping it to the original global.console of V8. This enables applications to send messages to the inspector console programmatically. Fixes: #21651 PR-URL: #21659 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
- Loading branch information
Showing
5 changed files
with
62 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
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
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,39 @@ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
common.skipIfInspectorDisabled(); | ||
|
||
const { NodeInstance } = require('../common/inspector-helper.js'); | ||
const assert = require('assert'); | ||
|
||
async function runTest() { | ||
const script = 'require(\'inspector\').console.log(\'hello world\');'; | ||
const child = new NodeInstance('--inspect-brk=0', script, ''); | ||
|
||
let out = ''; | ||
child.on('stdout', (line) => out += line); | ||
|
||
const session = await child.connectInspectorSession(); | ||
|
||
const commands = [ | ||
{ 'method': 'Runtime.enable' }, | ||
{ 'method': 'Runtime.runIfWaitingForDebugger' } | ||
]; | ||
|
||
session.send(commands); | ||
|
||
const msg = await session.waitForNotification('Runtime.consoleAPICalled'); | ||
|
||
assert.strictEqual(msg.params.type, 'log'); | ||
assert.deepStrictEqual(msg.params.args, [{ | ||
type: 'string', | ||
value: 'hello world' | ||
}]); | ||
assert.strictEqual(out, ''); | ||
|
||
session.disconnect(); | ||
} | ||
|
||
common.crashOnUnhandledRejection(); | ||
runTest(); |