LibWeb+WebContent: Implement the WebDriver JSON clone steps for elements

This is needed by WPT to serialize NodeList instances.
This commit is contained in:
Timothy Flynn 2024-09-13 19:41:31 -04:00 committed by Tim Ledbetter
commit bf60765903
Notes: github-actions[bot] 2024-09-14 23:57:21 +00:00
5 changed files with 36 additions and 1 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/ShadowRoot.h>
@ -61,6 +62,13 @@ ErrorOr<Web::DOM::Element*, Web::WebDriver::Error> get_known_connected_element(S
return static_cast<Web::DOM::Element*>(node);
}
// https://w3c.github.io/webdriver/#dfn-is-stale
bool is_element_stale(Web::DOM::Node const& element)
{
// An element is stale if its node document is not the active document or if it is not connected.
return !element.document().is_active() || !element.is_connected();
}
// https://w3c.github.io/webdriver/#dfn-get-or-create-a-shadow-root-reference
ByteString get_or_create_a_shadow_root_reference(Web::DOM::ShadowRoot const& shadow_root)
{