diff options
author | Andreas Kling <kling@serenityos.org> | 2022-02-16 11:53:21 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-02-16 12:03:05 +0100 |
commit | 9c78c1bf818b6ca85ddbcf71a9931a9f01b5f6f6 (patch) | |
tree | d5655c0e8ad88ee6e4c21af1816b216a577b2259 | |
parent | 5caeb8b747a8844d7d0a6a4514ae7cb717da7ccd (diff) | |
download | serenity-9c78c1bf818b6ca85ddbcf71a9931a9f01b5f6f6.zip |
WebContent: Exit peacefully when client dies during synchronous IPC
If we're waiting for the client (typically Browser) to respond to a
synchronous IPC message from our side (e.g window.alert()) and the
client disconnects instead, just exit peacefully.
Ultimately a WebContent process lives to serve its client. When the
client dies, there is no need for WebContent anymore.
-rw-r--r-- | Userland/Services/WebContent/PageHost.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 255f767305..426dceb2e1 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -203,17 +203,31 @@ void PageHost::page_did_request_link_context_menu(const Gfx::IntPoint& content_p void PageHost::page_did_request_alert(const String& message) { - m_client.did_request_alert(message); + auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestAlert>(message); + if (!response) { + dbgln("WebContent client disconnected during DidRequestAlert. Exiting peacefully."); + exit(0); + } } bool PageHost::page_did_request_confirm(const String& message) { - return m_client.did_request_confirm(message); + auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestConfirm>(message); + if (!response) { + dbgln("WebContent client disconnected during DidRequestConfirm. Exiting peacefully."); + exit(0); + } + return response->take_result(); } String PageHost::page_did_request_prompt(const String& message, const String& default_) { - return m_client.did_request_prompt(message, default_); + auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestPrompt>(message, default_); + if (!response) { + dbgln("WebContent client disconnected during DidRequestPrompt. Exiting peacefully."); + exit(0); + } + return response->take_response(); } void PageHost::page_did_change_favicon(const Gfx::Bitmap& favicon) @@ -229,7 +243,12 @@ void PageHost::page_did_request_image_context_menu(const Gfx::IntPoint& content_ String PageHost::page_did_request_cookie(const URL& url, Web::Cookie::Source source) { - return m_client.did_request_cookie(url, static_cast<u8>(source)); + auto response = m_client.send_sync_but_allow_failure<Messages::WebContentClient::DidRequestCookie>(move(url), static_cast<u8>(source)); + if (!response) { + dbgln("WebContent client disconnected during DidRequestCookie. Exiting peacefully."); + exit(0); + } + return response->take_cookie(); } void PageHost::page_did_set_cookie(const URL& url, const Web::Cookie::ParsedCookie& cookie, Web::Cookie::Source source) |