feat(inspector): pipe console messages between terminal and inspector (#11134)

This commit adds support for piping console messages to inspector.

This is done by "wrapping" Deno's console implementation with default
console provided by V8 by the means of "Deno.core.callConsole" binding.

Effectively each call to "console.*" methods calls a method on Deno's
console and V8's console.
This commit is contained in:
Bartek Iwańczuk 2021-06-27 02:27:50 +02:00 committed by GitHub
parent 015f252066
commit 7b9737b9f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 119 additions and 19 deletions

View file

@ -4556,6 +4556,7 @@ console.log("finish");
child.wait().unwrap();
}
#[derive(Debug)]
enum TestStep {
StdOut(&'static str),
StdErr(&'static str),
@ -4806,6 +4807,9 @@ console.log("finish");
// Expect the number {i} on stdout.
let s = i.to_string();
assert_eq!(stdout_lines.next().unwrap(), s);
// Expect console.log
let s = r#"{"method":"Runtime.consoleAPICalled","#;
assert!(socket_rx.next().await.unwrap().starts_with(s));
// Expect hitting the `debugger` statement.
let s = r#"{"method":"Debugger.paused","#;
assert!(socket_rx.next().await.unwrap().starts_with(s));
@ -4918,6 +4922,7 @@ console.log("finish");
WsSend(
r#"{"id":6,"method":"Runtime.evaluate","params":{"expression":"console.error('done');","objectGroup":"console","includeCommandLineAPI":true,"silent":false,"contextId":1,"returnByValue":true,"generatePreview":true,"userGesture":true,"awaitPromise":false,"replMode":true}}"#,
),
WsRecv(r#"{"method":"Runtime.consoleAPICalled"#),
WsRecv(r#"{"id":6,"result":{"result":{"type":"undefined"}}}"#),
StdErr("done"),
];