LibWeb+WebContent: Partially implement the switch-to-frame endpoint

This is needed by the cookie tests for WPT.
This commit is contained in:
Timothy Flynn 2024-09-13 19:44:12 -04:00 committed by Tim Ledbetter
commit 60fa3752ee
Notes: github-actions[bot] 2024-09-14 23:57:15 +00:00
3 changed files with 53 additions and 25 deletions

View file

@ -45,6 +45,20 @@ JsonObject web_element_reference_object(Web::DOM::Node const& element)
return object;
}
// https://w3c.github.io/webdriver/#dfn-represents-a-web-element
bool represents_a_web_element(JsonValue const& value)
{
// An ECMAScript Object represents a web element if it has a web element identifier own property.
if (!value.is_object())
return false;
auto const& object = value.as_object();
if (!object.has_string("name"sv) || !object.has_string("value"sv))
return false;
return object.get_byte_string("name"sv) == web_element_identifier;
}
// https://w3c.github.io/webdriver/#dfn-get-a-known-connected-element
ErrorOr<Web::DOM::Element*, Web::WebDriver::Error> get_known_connected_element(StringView element_id)
{