mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
WebDriver: Correctly report the client's readiness state
This commit is contained in:
parent
dcfc552d25
commit
e53df7e6c9
Notes:
github-actions[bot]
2025-02-17 16:15:34 +00:00
Author: https://github.com/trflynn89
Commit: e53df7e6c9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3600
1 changed files with 16 additions and 5 deletions
|
@ -106,21 +106,32 @@ Web::WebDriver::Response Client::delete_session(Web::WebDriver::Parameters param
|
||||||
return JsonValue {};
|
return JsonValue {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/webdriver/#dfn-readiness-state
|
||||||
|
static bool readiness_state()
|
||||||
|
{
|
||||||
|
// The readiness state of a remote end indicates whether it is free to accept new connections. It must be false if
|
||||||
|
// the implementation is an endpoint node and the list of active HTTP sessions is not empty, or otherwise if the
|
||||||
|
// remote end is known to be in a state in which attempting to create new sessions would fail. In all other cases it
|
||||||
|
// must be true.
|
||||||
|
return Session::session_count(Web::WebDriver::SessionFlags::Http) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
// 8.3 Status, https://w3c.github.io/webdriver/#dfn-status
|
// 8.3 Status, https://w3c.github.io/webdriver/#dfn-status
|
||||||
// GET /status
|
// GET /status
|
||||||
Web::WebDriver::Response Client::get_status(Web::WebDriver::Parameters, JsonValue)
|
Web::WebDriver::Response Client::get_status(Web::WebDriver::Parameters, JsonValue)
|
||||||
{
|
{
|
||||||
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /status");
|
dbgln_if(WEBDRIVER_DEBUG, "Handling GET /status");
|
||||||
|
|
||||||
|
auto readiness_state = WebDriver::readiness_state();
|
||||||
|
|
||||||
// 1. Let body be a new JSON Object with the following properties:
|
// 1. Let body be a new JSON Object with the following properties:
|
||||||
// "ready"
|
// "ready"
|
||||||
// The remote end’s readiness state.
|
// The remote end's readiness state.
|
||||||
// "message"
|
// "message"
|
||||||
// An implementation-defined string explaining the remote end’s readiness state.
|
// An implementation-defined string explaining the remote end's readiness state.
|
||||||
// FIXME: Report if we are somehow not ready.
|
|
||||||
JsonObject body;
|
JsonObject body;
|
||||||
body.set("ready", true);
|
body.set("ready", readiness_state);
|
||||||
body.set("message", "Ready to start some sessions!");
|
body.set("message", ByteString::formatted("{} to accept a new session", readiness_state ? "Ready"sv : "Not ready"sv));
|
||||||
|
|
||||||
// 2. Return success with data body.
|
// 2. Return success with data body.
|
||||||
return JsonValue { body };
|
return JsonValue { body };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue