diff options
author | Sam Atkins <atkinssj@gmail.com> | 2021-09-01 17:21:48 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-06 18:20:26 +0200 |
commit | ca2c1299233678cb4fe7fcdb9ded21e8bdde5d0e (patch) | |
tree | df73b7b0184d55e12f464e15bd341cb34b5e13a9 /Userland/Applications/Browser/Tab.cpp | |
parent | 2b2158595fc60c86468cead2d9f9a322e791c021 (diff) | |
download | serenity-ca2c1299233678cb4fe7fcdb9ded21e8bdde5d0e.zip |
Browser: Reconnect the JS console when the current page changes
Previously, it would keep a pointer to the interpreter of the previous
page, which resulted in Crashy Fun Times.
This also changes the clearing behavior - instead of clearing the
console output every time the window is shown, we clear it when the page
changes. This is more useful, since before you would lose any log
messages that had happened before opening the window.
Diffstat (limited to 'Userland/Applications/Browser/Tab.cpp')
-rw-r--r-- | Userland/Applications/Browser/Tab.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index 0a292b4119..13deed226b 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -178,11 +178,19 @@ Tab::Tab(BrowserWindow& window) if (m_dom_inspector_widget) m_dom_inspector_widget->clear_dom_json(); + + if (m_console_widget) + m_console_widget->clear_output(); }; hooks().on_load_finish = [this](auto&) { if (m_dom_inspector_widget) m_web_content_view->inspect_dom_tree(); + + // FIXME: This is called after the page has finished loading, which means any log messages + // that happen *while* it is loading (such as inline <script>s) will be lost. + if (m_console_widget) + m_web_content_view->js_console_initialize(); }; hooks().on_link_click = [this](auto& url, auto& target, unsigned modifiers) { @@ -512,11 +520,9 @@ void Tab::show_console_window() m_console_widget->on_js_input = [this](String const& js_source) { m_web_content_view->js_console_input(js_source); }; + m_web_content_view->js_console_initialize(); } - m_console_widget->clear_output(); - m_web_content_view->js_console_initialize(); - auto* window = m_console_widget->window(); window->show(); window->move_to_front(); |