mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implement tag name selector for FindElements WebDriver command
This commit is contained in:
parent
7d5b324bda
commit
dec73e4cea
5 changed files with 47 additions and 14 deletions
|
@ -2035,6 +2035,14 @@ impl ScriptThread {
|
|||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FindElementsTagName(selector, reply) => {
|
||||
webdriver_handlers::handle_find_elements_tag_name(
|
||||
&*documents,
|
||||
pipeline_id,
|
||||
selector,
|
||||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FindElementElementCSS(selector, element_id, reply) => {
|
||||
webdriver_handlers::handle_find_element_element_css(
|
||||
&*documents,
|
||||
|
|
|
@ -223,6 +223,25 @@ pub fn handle_find_elements_css(
|
|||
reply.send(node_ids).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_find_elements_tag_name(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
selector: String,
|
||||
reply: IpcSender<Result<Vec<String>, ()>>,
|
||||
) {
|
||||
let node_ids = documents
|
||||
.find_document(pipeline)
|
||||
.ok_or(())
|
||||
.and_then(|doc| Ok(doc.GetElementsByTagName(DOMString::from(selector))))
|
||||
.map(|nodes| {
|
||||
nodes
|
||||
.elements_iter()
|
||||
.map(|x| x.upcast::<Node>().unique_id())
|
||||
.collect::<Vec<String>>()
|
||||
});
|
||||
reply.send(node_ids).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_find_element_element_css(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue