LibWeb+WebContent+WebDriver: Implement the Perform Actions endpoint

Similar to script execution, this spins the WebDriver process until the
action is complete (rather than spinning the WebContent process, which
we've seen result in deadlocks).
This commit is contained in:
Timothy Flynn 2024-09-29 09:40:17 -04:00 committed by Andreas Kling
commit 709deeb482
Notes: github-actions[bot] 2024-10-01 09:03:18 +00:00
10 changed files with 83 additions and 16 deletions

View file

@ -3,7 +3,7 @@
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
* Copyright (c) 2022-2024, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -201,4 +201,22 @@ Web::WebDriver::Response Session::execute_script(JsonValue payload, ScriptMode m
return response.release_value();
}
Web::WebDriver::Response Session::perform_actions(JsonValue payload) const
{
ScopeGuard guard { [&]() { web_content_connection().on_actions_performed = nullptr; } };
Optional<Web::WebDriver::Response> response;
web_content_connection().on_actions_performed = [&](auto result) {
response = move(result);
};
TRY(web_content_connection().perform_actions(move(payload)));
Core::EventLoop::current().spin_until([&]() {
return response.has_value();
});
return response.release_value();
}
}