From a33cad119768f7af3a5a6d3785fdf2ff34d5d537 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Sat, 15 Oct 2022 12:34:28 +0200 Subject: [PATCH] WebDriver: Fix HTTP Status for 'no such window' error The 'no such window' error returns a 404, not a 400. --- Userland/Services/WebDriver/Session.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp index 36fd0110a1..0eb15c9955 100644 --- a/Userland/Services/WebDriver/Session.cpp +++ b/Userland/Services/WebDriver/Session.cpp @@ -74,7 +74,7 @@ ErrorOr> Session::delete_window() // 1. If the current top-level browsing context is no longer open, return error with error code no such window. auto current_window = get_window_object(); if (!current_window.has_value()) - return Variant(HttpError { 400, "no such window", "Window not found" }); + return Variant(HttpError { 404, "no such window", "Window not found" }); // 2. Close the current top-level browsing context. m_windows.remove(m_current_window_handle); @@ -96,7 +96,7 @@ ErrorOr Session::post_url(JsonValue const& payload) // 1. If the current top-level browsing context is no longer open, return error with error code no such window. auto current_window = get_window_object(); if (!current_window.has_value()) - return HttpError { 400, "no such window", "Window not found" }; + return HttpError { 404, "no such window", "Window not found" }; // FIXME 2. Handle any user prompts and return its value if it is an error. @@ -132,7 +132,7 @@ ErrorOr Session::get_url() // 1. If the current top-level browsing context is no longer open, return error with error code no such window. auto current_window = get_window_object(); if (!current_window.has_value()) - return HttpError { 400, "no such window", "Window not found" }; + return HttpError { 404, "no such window", "Window not found" }; // FIXME: 2. Handle any user prompts and return its value if it is an error. @@ -149,7 +149,7 @@ ErrorOr Session::get_title() // 1. If the current top-level browsing context is no longer open, return error with error code no such window. auto current_window = get_window_object(); if (!current_window.has_value()) - return HttpError { 400, "no such window", "Window not found" }; + return HttpError { 404, "no such window", "Window not found" }; // FIXME: 2. Handle any user prompts and return its value if it is an error.