mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
[webdriver] Implement get shadow root (#37280)
Implement Get Element Shadow Root https://www.w3.org/TR/webdriver2/#dfn-get-element-shadow-root cc: @xiaochengh, @yezhizhen, @PotatoCP Testing: `\tests\wpt\tests\webdriver\tests\classic\get_element_shadow_root\get.py` is blocked by `no_browsing_context` and `closed_window` pass for other sub-tests. Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
parent
c808ff7666
commit
aeca81c091
4 changed files with 53 additions and 0 deletions
|
@ -2280,6 +2280,14 @@ impl ScriptThread {
|
|||
can_gc,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::GetElementShadowRoot(element_id, reply) => {
|
||||
webdriver_handlers::handle_get_element_shadow_root(
|
||||
&documents,
|
||||
pipeline_id,
|
||||
element_id,
|
||||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::ElementClick(element_id, reply) => {
|
||||
webdriver_handlers::handle_element_click(
|
||||
&documents,
|
||||
|
|
|
@ -843,6 +843,27 @@ pub(crate) fn handle_find_element_elements_tag_name(
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
/// <https://www.w3.org/TR/webdriver2/#dfn-get-element-shadow-root>
|
||||
pub(crate) fn handle_get_element_shadow_root(
|
||||
documents: &DocumentCollection,
|
||||
pipeline: PipelineId,
|
||||
element_id: String,
|
||||
reply: IpcSender<Result<Option<String>, ErrorStatus>>,
|
||||
) {
|
||||
reply
|
||||
.send(
|
||||
find_node_by_unique_id(documents, pipeline, element_id).and_then(|node| match node
|
||||
.downcast::<Element>(
|
||||
) {
|
||||
Some(element) => Ok(element
|
||||
.GetShadowRoot()
|
||||
.map(|x| x.upcast::<Node>().unique_id(pipeline))),
|
||||
None => Err(ErrorStatus::NoSuchElement),
|
||||
}),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn handle_will_send_keys(
|
||||
documents: &DocumentCollection,
|
||||
pipeline: PipelineId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue