LibWeb: Update (not replace) timeout values in WebDriver's Set Timeouts

Contradictory to the spec, the Set Timeouts endpoint should update the
existing timeouts configuration in-place, rather than replacing it. WPT
expects this, and other browsers already implement this endpoint this
way.
This commit is contained in:
Timothy Flynn 2024-10-11 15:15:06 -04:00 committed by Andreas Kling
commit dae6200c1d
Notes: github-actions[bot] 2024-10-12 13:03:32 +00:00
3 changed files with 20 additions and 7 deletions

View file

@ -243,11 +243,15 @@ Messages::WebDriverClient::GetTimeoutsResponse WebDriverConnection::get_timeouts
// 9.2 Set Timeouts, https://w3c.github.io/webdriver/#dfn-set-timeouts
Messages::WebDriverClient::SetTimeoutsResponse WebDriverConnection::set_timeouts(JsonValue const& payload)
{
// FIXME: Spec issue: As written, the spec replaces the timeouts configuration with the newly provided values. But
// all other implementations update the existing configuration with any new values instead. WPT relies on
// this behavior, and sends us one timeout value at time.
// https://github.com/w3c/webdriver/issues/1596
// 1. Let timeouts be the result of trying to JSON deserialize as a timeouts configuration the requests parameters.
auto timeouts = TRY(Web::WebDriver::json_deserialize_as_a_timeouts_configuration(payload));
TRY(Web::WebDriver::json_deserialize_as_a_timeouts_configuration_into(payload, m_timeouts_configuration));
// 2. Make the session timeouts the new timeouts.
m_timeouts_configuration = move(timeouts);
// 3. Return success with data null.
return JsonValue {};