1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

Browser+LibWebView: Add WebDriver IPC plumbing for executing scripts

This commit is contained in:
Linus Groh 2022-11-02 18:08:48 +00:00
parent b572a91a6f
commit 747ba2a88f
7 changed files with 40 additions and 0 deletions

View file

@ -11,6 +11,7 @@
#include <AK/Vector.h>
#include <LibWeb/Cookie/Cookie.h>
#include <LibWeb/Cookie/ParsedCookie.h>
#include <LibWebView/WebContentClient.h>
namespace Browser {
@ -116,6 +117,21 @@ void WebDriverConnection::minimize_window()
browser_window->set_minimized(true);
}
Messages::WebDriverSessionClient::ExecuteScriptResponse WebDriverConnection::execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)
{
dbgln("WebDriverConnection: execute_script");
if (auto browser_window = m_browser_window.strong_ref()) {
auto& tab = browser_window->active_tab();
if (tab.webdriver_endpoints().on_execute_script) {
auto response = tab.webdriver_endpoints().on_execute_script(body, json_arguments, timeout, async);
// WebContentServer's and WebDriverSessionClient's ExecuteScriptResponse have an identical
// structure but are distinct types, so we have to convert here.
return { response.result_type(), response.json_result() };
}
}
return { {} };
}
Messages::WebDriverSessionClient::GetAllCookiesResponse WebDriverConnection::get_all_cookies()
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: get_cookies");