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

Browser+WebContent+WebDriver: Move Find Elements From Element to WC

This also lets us remove the element location strategy and some
WebContent IPC from Browser/LibWebView now that they are unused.
This commit is contained in:
Timothy Flynn 2022-11-09 15:25:23 -05:00 committed by Linus Groh
parent 5a750dc58c
commit 560da56a1d
16 changed files with 31 additions and 271 deletions

View file

@ -607,14 +607,6 @@ void BrowserWindow::create_new_tab(URL url, bool activate)
return active_tab().view().take_screenshot();
};
new_tab.webdriver_endpoints().on_get_document_element = [this]() {
return active_tab().view().get_document_element();
};
new_tab.webdriver_endpoints().on_query_selector_all = [this](i32 start_node_id, String const& selector) {
return active_tab().view().query_selector_all(start_node_id, selector);
};
new_tab.webdriver_endpoints().on_scroll_element_into_view = [this](i32 element_id) {
active_tab().view().scroll_element_into_view(element_id);
};

View file

@ -136,28 +136,6 @@ void WebDriverConnection::update_cookie(Web::Cookie::Cookie const& cookie)
}
}
Messages::WebDriverSessionClient::GetDocumentElementResponse WebDriverConnection::get_document_element()
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: get_document_element");
if (auto browser_window = m_browser_window.strong_ref()) {
auto& tab = browser_window->active_tab();
if (tab.webdriver_endpoints().on_get_document_element)
return { tab.webdriver_endpoints().on_get_document_element() };
}
return { {} };
}
Messages::WebDriverSessionClient::QuerySelectorAllResponse WebDriverConnection::query_selector_all(i32 start_node_id, String const& selector)
{
dbgln_if(WEBDRIVER_DEBUG, "WebDriverConnection: query_selector_all");
if (auto browser_window = m_browser_window.strong_ref()) {
auto& tab = browser_window->active_tab();
if (tab.webdriver_endpoints().on_query_selector_all)
return { tab.webdriver_endpoints().on_query_selector_all(start_node_id, selector) };
}
return { {} };
}
void WebDriverConnection::scroll_element_into_view(i32 element_id)
{
dbgln("WebDriverConnection: scroll_element_into_view {}", element_id);

View file

@ -48,8 +48,6 @@ public:
virtual Messages::WebDriverSessionClient::GetNamedCookieResponse get_named_cookie(String const& name) override;
virtual void add_cookie(Web::Cookie::ParsedCookie const&) override;
virtual void update_cookie(Web::Cookie::Cookie const&) override;
virtual Messages::WebDriverSessionClient::GetDocumentElementResponse get_document_element() override;
virtual Messages::WebDriverSessionClient::QuerySelectorAllResponse query_selector_all(i32 start_node_id, String const& selector) override;
virtual void scroll_element_into_view(i32 element_id) override;
virtual Messages::WebDriverSessionClient::IsElementSelectedResponse is_element_selected(i32 element_id) override;
virtual Messages::WebDriverSessionClient::GetElementAttributeResponse get_element_attribute(i32 element_id, String const& name) override;

View file

@ -23,8 +23,6 @@ public:
WebDriverEndpoints() = default;
~WebDriverEndpoints() = default;
Function<Optional<i32>()> on_get_document_element;
Function<Optional<Vector<i32>>(i32 start_node_id, String const&)> on_query_selector_all;
Function<void(i32 element_id)> on_scroll_element_into_view;
Function<bool(i32 element_id)> on_is_element_selected;
Function<Optional<String>(i32 element_id, String const&)> on_get_element_attribute;

View file

@ -24,8 +24,6 @@ endpoint WebDriverSessionClient {
get_named_cookie(String name) => (Optional<Web::Cookie::Cookie> cookie)
add_cookie(Web::Cookie::ParsedCookie cookie) =|
update_cookie(Web::Cookie::Cookie cookie) =|
get_document_element() => (Optional<i32> document_element_id)
query_selector_all(i32 start_node_id, String selector) => (Optional<Vector<i32>> elements_ids)
scroll_element_into_view(i32 element_id) => ()
is_element_selected(i32 element_id) => (bool selected)
get_element_attribute(i32 element_id, String name) => (Optional<String> atttibute)