WebContent+WebDriver: Make the element locator endpoints asynchronous

We currently spin the event loop to wait for the specified element to
become available. As we've seen with other endpoints, this can result
in dead locks if another web component also spins the event loop.

This patch makes the locator implementations asynchronous.
This commit is contained in:
Timothy Flynn 2024-10-30 15:26:04 -04:00 committed by Tim Ledbetter
commit ad9d623664
Notes: github-actions[bot] 2024-10-31 00:43:33 +00:00
8 changed files with 276 additions and 118 deletions

View file

@ -237,6 +237,48 @@ Web::WebDriver::Response Session::fullscreen_window() const
});
}
Web::WebDriver::Response Session::find_element(JsonValue payload) const
{
return perform_async_action(web_content_connection().on_find_elements_complete, [&]() {
return web_content_connection().find_element(move(payload));
});
}
Web::WebDriver::Response Session::find_elements(JsonValue payload) const
{
return perform_async_action(web_content_connection().on_find_elements_complete, [&]() {
return web_content_connection().find_elements(move(payload));
});
}
Web::WebDriver::Response Session::find_element_from_element(String element_id, JsonValue payload) const
{
return perform_async_action(web_content_connection().on_find_elements_complete, [&]() {
return web_content_connection().find_element_from_element(move(payload), move(element_id));
});
}
Web::WebDriver::Response Session::find_elements_from_element(String element_id, JsonValue payload) const
{
return perform_async_action(web_content_connection().on_find_elements_complete, [&]() {
return web_content_connection().find_elements_from_element(move(payload), move(element_id));
});
}
Web::WebDriver::Response Session::find_element_from_shadow_root(String shadow_id, JsonValue payload) const
{
return perform_async_action(web_content_connection().on_find_elements_complete, [&]() {
return web_content_connection().find_element_from_shadow_root(move(payload), move(shadow_id));
});
}
Web::WebDriver::Response Session::find_elements_from_shadow_root(String shadow_id, JsonValue payload) const
{
return perform_async_action(web_content_connection().on_find_elements_complete, [&]() {
return web_content_connection().find_elements_from_shadow_root(move(payload), move(shadow_id));
});
}
Web::WebDriver::Response Session::execute_script(JsonValue payload, ScriptMode mode) const
{
return perform_async_action(web_content_connection().on_script_executed, [&]() {