1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

Browser+WebContent+WebDriver: Move Get Element CSS Value to WebContent

This commit is contained in:
Timothy Flynn 2022-11-10 10:11:04 -05:00 committed by Linus Groh
parent 3c00d0e92b
commit 06f1b8825c
16 changed files with 39 additions and 121 deletions

View file

@ -323,32 +323,6 @@ static ErrorOr<i32, Web::WebDriver::Error> get_known_connected_element(StringVie
return maybe_element_id.release_value();
}
// 12.4.4 Get Element CSS Value, https://w3c.github.io/webdriver/#dfn-get-element-css-value
Web::WebDriver::Response Session::get_element_css_value(JsonValue const&, StringView parameter_element_id, StringView property_name)
{
// 1. If the current browsing context is no longer open, return error with error code no such window.
TRY(check_for_open_top_level_browsing_context_or_return_error());
// FIXME: 2. Handle any user prompts and return its value if it is an error.
// 3. Let element be the result of trying to get a known connected element with url variable element id.
auto element_id = TRY(get_known_connected_element(parameter_element_id));
// 4. Let computed value be the result of the first matching condition:
// -> current browsing contexts active documents type is not "xml"
// computed value of parameter property name from elements style declarations. property name is obtained from url variables.
// -> Otherwise
// "" (empty string)
auto active_documents_type = m_browser_connection->get_active_documents_type();
if (active_documents_type == "xml")
return JsonValue("");
auto computed_value = m_browser_connection->get_computed_value_for_element(element_id, property_name);
// 5. Return success with data computed value.
return JsonValue(computed_value);
}
// 12.4.5 Get Element Text, https://w3c.github.io/webdriver/#dfn-get-element-text
Web::WebDriver::Response Session::get_element_text(JsonValue const&, StringView parameter_element_id)
{