diff --git a/Userland/Services/WebContent/WebContentConsoleClient.cpp b/Userland/Services/WebContent/WebContentConsoleClient.cpp
index eb87b410cd8..54a0cc6ab98 100644
--- a/Userland/Services/WebContent/WebContentConsoleClient.cpp
+++ b/Userland/Services/WebContent/WebContentConsoleClient.cpp
@@ -39,7 +39,16 @@ void WebContentConsoleClient::handle_input(String const& js_source)
output_html.append(String::formatted("
{}
", escape_html_entities(hint)));
m_interpreter->vm().throw_exception(*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(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()) {