mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
WebDriver: Replace hardcoded timeout with a TimeoutsConfiguration struct
This commit is contained in:
parent
e5a9f030f2
commit
f0a8e3bc05
Notes:
sideshowbarker
2024-07-17 05:21:06 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/f0a8e3bc05 Pull-request: https://github.com/SerenityOS/serenity/pull/15700 Reviewed-by: https://github.com/TobyAsE ✅
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -265,7 +266,7 @@ static JsonObject web_element_reference_object(Session::LocalElement const& elem
|
|||
ErrorOr<JsonArray, HttpError> Session::find(Session::LocalElement const& start_node, StringView const& using_, StringView const& value)
|
||||
{
|
||||
// 1. Let end time be the current time plus the session implicit wait timeout.
|
||||
auto end_time = Core::DateTime::from_timestamp(Core::DateTime::now().timestamp() + s_session_timeouts);
|
||||
auto end_time = Core::DateTime::from_timestamp(Core::DateTime::now().timestamp() + m_timeouts_configuration.implicit_wait_timeout / 1000);
|
||||
|
||||
// 2. Let location strategy be equal to using.
|
||||
auto location_strategy = using_;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Florent Castelli <florent.castelli@gmail.com>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -11,6 +12,7 @@
|
|||
#include <AK/RefPtr.h>
|
||||
#include <WebDriver/BrowserConnection.h>
|
||||
#include <WebDriver/HttpError.h>
|
||||
#include <WebDriver/TimeoutsConfiguration.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace WebDriver {
|
||||
|
@ -55,10 +57,6 @@ public:
|
|||
ErrorOr<JsonValue, HttpError> delete_cookie(StringView const& name);
|
||||
ErrorOr<JsonValue, HttpError> delete_all_cookies();
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-session-script-timeout
|
||||
// NOTE: Hardcoded timeouts to 30 seconds.
|
||||
static int const s_session_timeouts = 30;
|
||||
|
||||
private:
|
||||
void delete_cookies(Optional<StringView> const& name = {});
|
||||
ErrorOr<JsonArray, HttpError> find(LocalElement const& start_node, StringView const& location_strategy, StringView const& selector);
|
||||
|
@ -84,6 +82,9 @@ private:
|
|||
String m_current_window_handle;
|
||||
RefPtr<Core::LocalServer> m_local_server;
|
||||
RefPtr<BrowserConnection> m_browser_connection;
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-session-script-timeout
|
||||
TimeoutsConfiguration m_timeouts_configuration;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
21
Userland/Services/WebDriver/TimeoutsConfiguration.h
Normal file
21
Userland/Services/WebDriver/TimeoutsConfiguration.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Optional.h>
|
||||
|
||||
namespace WebDriver {
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-timeouts-configuration
|
||||
struct TimeoutsConfiguration {
|
||||
Optional<u64> script_timeout { 30'000 };
|
||||
u64 page_load_timeout { 300'000 };
|
||||
u64 implicit_wait_timeout { 0 };
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue