mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb+WebContent: Implement the WebDriver JSON clone steps for elements
This is needed by WPT to serialize NodeList instances.
This commit is contained in:
parent
2dc8cad785
commit
bf60765903
Notes:
github-actions[bot]
2024-09-14 23:57:21 +00:00
Author: https://github.com/trflynn89
Commit: bf60765903
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1403
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 36 additions and 1 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Platform/EventLoopPlugin.h>
|
||||
#include <LibWeb/WebDriver/Contexts.h>
|
||||
#include <LibWeb/WebDriver/ElementReference.h>
|
||||
#include <LibWeb/WebDriver/ExecuteScript.h>
|
||||
|
||||
namespace Web::WebDriver {
|
||||
|
@ -109,7 +110,25 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> internal_json_clone_algorithm
|
|||
return ExecuteScriptResultType::JavaScriptError;
|
||||
|
||||
// FIXME: -> a collection
|
||||
// FIXME: -> instance of element
|
||||
|
||||
// -> instance of element
|
||||
if (value.is_object() && is<DOM::Element>(value.as_object())) {
|
||||
auto const& element = static_cast<DOM::Element const&>(value.as_object());
|
||||
|
||||
// If the element is stale, return error with error code stale element reference.
|
||||
if (is_element_stale(element)) {
|
||||
return ExecuteScriptResultType::StaleElement;
|
||||
}
|
||||
// Otherwise:
|
||||
else {
|
||||
// 1. Let reference be the web element reference object for session and value.
|
||||
auto reference = web_element_reference_object(element);
|
||||
|
||||
// 2. Return success with data reference.
|
||||
return reference;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: -> instance of shadow root
|
||||
|
||||
// -> a WindowProxy object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue