1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:57:46 +00:00

Browser: Implemented out of process JS console

Added input hook into console widget to allow input to be captured and
sent to the external JS console via IPC.

Output from the external JS console is fed into the console widget
via handle_js_console_output().
This commit is contained in:
Brandon Scott 2021-02-27 21:53:20 -06:00 committed by Andreas Kling
parent 0682af7b65
commit 269ec8b1f9
3 changed files with 41 additions and 1 deletions

View file

@ -84,6 +84,13 @@ ConsoleWidget::ConsoleWidget()
print_source_line(js_source);
if (on_js_input)
on_js_input(js_source);
// no interpreter being set means we are running in multi-process mode
if (!m_interpreter)
return;
auto parser = JS::Parser(JS::Lexer(js_source));
auto program = parser.parse_program();
@ -130,6 +137,15 @@ ConsoleWidget::~ConsoleWidget()
{
}
void ConsoleWidget::handle_js_console_output(const String& method, const String& line)
{
if (method == "html") {
print_html(line);
} else if (method == "clear") {
clear_output();
}
}
void ConsoleWidget::set_interpreter(WeakPtr<JS::Interpreter> interpreter)
{
if (m_interpreter.ptr() == interpreter.ptr())