1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:37:34 +00:00

WebDriver: Pass StringView by value

See: 8b1108e485.
This commit is contained in:
Timothy Flynn 2022-11-03 15:58:13 -04:00 committed by Tim Flynn
parent 92cb67522d
commit d907fb304e
2 changed files with 15 additions and 15 deletions

View file

@ -465,7 +465,7 @@ static ErrorOr<i32, WebDriverError> get_known_connected_element(StringView eleme
} }
// https://w3c.github.io/webdriver/#dfn-find // https://w3c.github.io/webdriver/#dfn-find
ErrorOr<JsonArray, WebDriverError> Session::find(Session::LocalElement const& start_node, StringView const& using_, StringView const& value) ErrorOr<JsonArray, WebDriverError> Session::find(Session::LocalElement const& start_node, StringView using_, StringView value)
{ {
// 1. Let end time be the current time plus the session implicit wait timeout. // 1. Let end time be the current time plus the session implicit wait timeout.
auto end_time = Time::now_monotonic() + Time::from_milliseconds(static_cast<i64>(m_timeouts_configuration.implicit_wait_timeout)); auto end_time = Time::now_monotonic() + Time::from_milliseconds(static_cast<i64>(m_timeouts_configuration.implicit_wait_timeout));
@ -514,7 +514,7 @@ Vector<Session::LocatorStrategy> Session::s_locator_strategies = {
}; };
// https://w3c.github.io/webdriver/#css-selectors // https://w3c.github.io/webdriver/#css-selectors
ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_css_selectors(Session::LocalElement const& start_node, StringView const& selector) ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_css_selectors(Session::LocalElement const& start_node, StringView selector)
{ {
// 1. Let elements be the result of calling querySelectorAll() with start node as this and selector as the argument. // 1. Let elements be the result of calling querySelectorAll() with start node as this and selector as the argument.
// If this causes an exception to be thrown, return error with error code invalid selector. // If this causes an exception to be thrown, return error with error code invalid selector.
@ -533,28 +533,28 @@ ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy
} }
// https://w3c.github.io/webdriver/#link-text // https://w3c.github.io/webdriver/#link-text
ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_link_text(Session::LocalElement const&, StringView const&) ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_link_text(Session::LocalElement const&, StringView)
{ {
// FIXME: Implement // FIXME: Implement
return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy link text"); return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy link text");
} }
// https://w3c.github.io/webdriver/#partial-link-text // https://w3c.github.io/webdriver/#partial-link-text
ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_partial_link_text(Session::LocalElement const&, StringView const&) ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_partial_link_text(Session::LocalElement const&, StringView)
{ {
// FIXME: Implement // FIXME: Implement
return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy partial link text"); return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy partial link text");
} }
// https://w3c.github.io/webdriver/#tag-name // https://w3c.github.io/webdriver/#tag-name
ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_tag_name(Session::LocalElement const&, StringView const&) ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_tag_name(Session::LocalElement const&, StringView)
{ {
// FIXME: Implement // FIXME: Implement
return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy tag name"); return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy tag name");
} }
// https://w3c.github.io/webdriver/#xpath // https://w3c.github.io/webdriver/#xpath
ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_x_path(Session::LocalElement const&, StringView const&) ErrorOr<Vector<Session::LocalElement>, WebDriverError> Session::locator_strategy_x_path(Session::LocalElement const&, StringView)
{ {
// FIXME: Implement // FIXME: Implement
return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy XPath"); return WebDriverError::from_code(ErrorCode::UnsupportedOperation, "Not implemented: locator strategy XPath");
@ -1253,7 +1253,7 @@ void Session::delete_cookies(Optional<StringView> const& name)
} }
// 14.4 Delete Cookie, https://w3c.github.io/webdriver/#dfn-delete-cookie // 14.4 Delete Cookie, https://w3c.github.io/webdriver/#dfn-delete-cookie
ErrorOr<JsonValue, WebDriverError> Session::delete_cookie(StringView const& name) ErrorOr<JsonValue, WebDriverError> Session::delete_cookie(StringView name)
{ {
// 1. If the current browsing context is no longer open, return error with error code no such window. // 1. If the current browsing context is no longer open, return error with error code no such window.
TRY(check_for_open_top_level_browsing_context_or_return_error()); TRY(check_for_open_top_level_browsing_context_or_return_error());

View file

@ -72,15 +72,15 @@ public:
ErrorOr<JsonValue, WebDriverError> get_all_cookies(); ErrorOr<JsonValue, WebDriverError> get_all_cookies();
ErrorOr<JsonValue, WebDriverError> get_named_cookie(String const& name); ErrorOr<JsonValue, WebDriverError> get_named_cookie(String const& name);
ErrorOr<JsonValue, WebDriverError> add_cookie(JsonValue const& payload); ErrorOr<JsonValue, WebDriverError> add_cookie(JsonValue const& payload);
ErrorOr<JsonValue, WebDriverError> delete_cookie(StringView const& name); ErrorOr<JsonValue, WebDriverError> delete_cookie(StringView name);
ErrorOr<JsonValue, WebDriverError> delete_all_cookies(); ErrorOr<JsonValue, WebDriverError> delete_all_cookies();
ErrorOr<JsonValue, WebDriverError> take_screenshot(); ErrorOr<JsonValue, WebDriverError> take_screenshot();
private: private:
void delete_cookies(Optional<StringView> const& name = {}); void delete_cookies(Optional<StringView> const& name = {});
ErrorOr<JsonArray, WebDriverError> find(LocalElement const& start_node, StringView const& location_strategy, StringView const& selector); ErrorOr<JsonArray, WebDriverError> find(LocalElement const& start_node, StringView location_strategy, StringView selector);
using ElementLocationStrategyHandler = ErrorOr<Vector<LocalElement>, WebDriverError> (Session::*)(LocalElement const&, StringView const&); using ElementLocationStrategyHandler = ErrorOr<Vector<LocalElement>, WebDriverError> (Session::*)(LocalElement const&, StringView);
struct LocatorStrategy { struct LocatorStrategy {
String name; String name;
ElementLocationStrategyHandler handler; ElementLocationStrategyHandler handler;
@ -88,11 +88,11 @@ private:
static Vector<LocatorStrategy> s_locator_strategies; static Vector<LocatorStrategy> s_locator_strategies;
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_css_selectors(LocalElement const&, StringView const&); ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_css_selectors(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_link_text(LocalElement const&, StringView const&); ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_link_text(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_partial_link_text(LocalElement const&, StringView const&); ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_partial_link_text(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_tag_name(LocalElement const&, StringView const&); ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_tag_name(LocalElement const&, StringView);
ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_x_path(LocalElement const&, StringView const&); ErrorOr<Vector<LocalElement>, WebDriverError> locator_strategy_x_path(LocalElement const&, StringView);
NonnullRefPtr<Client> m_client; NonnullRefPtr<Client> m_client;
bool m_started { false }; bool m_started { false };