From 010be9b7c26b2d28da539965acc66797f99dd356 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 7 Mar 2023 10:50:20 -0500 Subject: [PATCH] WebDriver: Do not throw an error when closing an inactive session The spec states to only try to close the session *if* it exists. This situation can occur when closing a session after a Close Window command, as the session will be closed automatically if it was the last window. --- Userland/Services/WebDriver/Client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp index 6af99076c3..d62b0f1542 100644 --- a/Userland/Services/WebDriver/Client.cpp +++ b/Userland/Services/WebDriver/Client.cpp @@ -184,8 +184,8 @@ Web::WebDriver::Response Client::delete_session(Web::WebDriver::Parameters param dbgln_if(WEBDRIVER_DEBUG, "Handling DELETE /session/"); // 1. If the current session is an active session, try to close the session. - auto session = TRY(find_session_with_id(parameters[0])); - TRY(session->stop()); + if (auto session = find_session_with_id(parameters[0]); !session.is_error()) + TRY(session.value()->stop()); // 2. Return success with data null. return JsonValue {};