mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
LibWeb: Fix that $0 was no longer accessible
We now set the realm (twice) on every console input. This can probably be avoided if we use two executing contexts one for the website the other for the console. This achieves a similar behavior but is not really nice and not really spec like.
This commit is contained in:
parent
04454efa72
commit
0d73487204
1 changed files with 9 additions and 0 deletions
|
@ -39,7 +39,16 @@ void WebContentConsoleClient::handle_input(String const& js_source)
|
|||
output_html.append(String::formatted("<pre>{}</pre>", escape_html_entities(hint)));
|
||||
m_interpreter->vm().throw_exception<JS::SyntaxError>(*m_console_global_object.cell(), error.to_string());
|
||||
} else {
|
||||
// FIXME: This is not the correct way to do this, we probably want to have
|
||||
// multiple execution contexts we switch between.
|
||||
auto& global_object_before = m_interpreter->realm().global_object();
|
||||
VERIFY(is<Web::Bindings::WindowObject>(global_object_before));
|
||||
auto& this_value_before = m_interpreter->realm().global_environment().global_this_value();
|
||||
m_interpreter->realm().set_global_object(*m_console_global_object.cell(), &global_object_before);
|
||||
|
||||
m_interpreter->run(*m_console_global_object.cell(), *program);
|
||||
|
||||
m_interpreter->realm().set_global_object(global_object_before, &this_value_before);
|
||||
}
|
||||
|
||||
if (m_interpreter->exception()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue