1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:17:34 +00:00

Browser+WebContent+WebDriver: Move Execute Async Script to WebContent

With this, WebDriverEndpoints is unused and removed :^)
This commit is contained in:
Timothy Flynn 2022-11-10 21:00:27 -05:00 committed by Linus Groh
parent 0b9803dc93
commit 31469ee45a
17 changed files with 35 additions and 161 deletions

View file

@ -607,10 +607,6 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
return active_tab().view().take_screenshot();
};
new_tab.webdriver_endpoints().on_execute_script = [this](String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async) {
return active_tab().view().webdriver_execute_script(body, json_arguments, timeout, async);
};
new_tab.load(url);
dbgln_if(SPAM_DEBUG, "Added new tab {:p}, loading {}", &new_tab, url);

View file

@ -8,7 +8,6 @@
#pragma once
#include "History.h"
#include "WebDriverEndpoints.h"
#include <AK/Optional.h>
#include <AK/URL.h>
#include <LibGUI/ActionGroup.h>
@ -74,7 +73,6 @@ public:
Function<OrderedHashMap<String, String>()> on_get_session_storage_entries;
Function<Gfx::ShareableBitmap()> on_take_screenshot;
WebDriverEndpoints& webdriver_endpoints() { return m_webdriver_endpoints; }
void enable_webdriver_mode();
enum class InspectorTarget {
@ -143,8 +141,6 @@ private:
Optional<URL> m_navigating_url;
WebDriverEndpoints m_webdriver_endpoints {};
bool m_loaded { false };
bool m_is_history_navigation { false };
};

View file

@ -58,21 +58,6 @@ void WebDriverConnection::forward()
browser_window->active_tab().go_forward();
}
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");

View file

@ -42,7 +42,6 @@ public:
virtual void refresh() override;
virtual void back() override;
virtual void forward() override;
virtual Messages::WebDriverSessionClient::ExecuteScriptResponse execute_script(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async) override;
virtual Messages::WebDriverSessionClient::GetAllCookiesResponse get_all_cookies() override;
virtual Messages::WebDriverSessionClient::GetNamedCookieResponse get_named_cookie(String const& name) override;
virtual void add_cookie(Web::Cookie::ParsedCookie const&) override;

View file

@ -1,29 +0,0 @@
/*
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <AK/Function.h>
#include <LibGfx/Rect.h>
#include <LibWeb/Forward.h>
namespace Messages::WebContentServer {
class WebdriverExecuteScriptResponse;
}
namespace Browser {
class WebDriverEndpoints {
public:
WebDriverEndpoints() = default;
~WebDriverEndpoints() = default;
Function<Messages::WebContentServer::WebdriverExecuteScriptResponse(String const& body, Vector<String> const& json_arguments, Optional<u64> const& timeout, bool async)> on_execute_script;
};
}

View file

@ -18,7 +18,6 @@ endpoint WebDriverSessionClient {
refresh() =|
back() =|
forward() =|
execute_script(String body, Vector<String> json_arguments, Optional<u64> timeout, bool async) => (Web::WebDriver::ExecuteScriptResultType result_type, String json_result)
get_all_cookies() => (Vector<Web::Cookie::Cookie> cookies)
get_named_cookie(String name) => (Optional<Web::Cookie::Cookie> cookie)
add_cookie(Web::Cookie::ParsedCookie cookie) =|