From a4f862a869c4967ab103f83fa81ac761d2fda502 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 10 Jan 2024 12:23:00 -0500 Subject: [PATCH] WebContent: Change the cookie setting IPC to be synchronous Considering an operation like the following: document.cookie = "cookie=value"; const value = document.cookie; If the IPC for the cookie setter is asynchronous, the getter can execute while the browser/SQLServer processes are still handling the setter. This is often seen when hammering the document with cookie requests. --- Userland/Services/WebContent/PageClient.cpp | 6 +++++- Userland/Services/WebContent/WebContentClient.ipc | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Userland/Services/WebContent/PageClient.cpp b/Userland/Services/WebContent/PageClient.cpp index 95e2af6ecd..7c1bf198b9 100644 --- a/Userland/Services/WebContent/PageClient.cpp +++ b/Userland/Services/WebContent/PageClient.cpp @@ -504,7 +504,11 @@ ByteString PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Sour void PageClient::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) { - client().async_did_set_cookie(url, cookie, static_cast(source)); + auto response = client().send_sync_but_allow_failure(url, cookie, static_cast(source)); + if (!response) { + dbgln("WebContent client disconnected during DidSetCookie. Exiting peacefully."); + exit(0); + } } void PageClient::page_did_update_cookie(Web::Cookie::Cookie cookie) diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc index a547283777..ea4cb5a482 100644 --- a/Userland/Services/WebContent/WebContentClient.ipc +++ b/Userland/Services/WebContent/WebContentClient.ipc @@ -54,7 +54,7 @@ endpoint WebContentClient did_request_all_cookies(URL url) => (Vector cookies) did_request_named_cookie(URL url, ByteString name) => (Optional cookie) did_request_cookie(URL url, u8 source) => (ByteString cookie) - did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) =| + did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) => () did_update_cookie(Web::Cookie::Cookie cookie) =| did_update_resource_count(i32 count_waiting) =| did_request_new_tab(Web::HTML::ActivateTab activate_tab) => (String handle)