mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
Implement WebDriver FindElementFromElement command
This commit is contained in:
parent
db29cb01b0
commit
46cd0d17ee
4 changed files with 66 additions and 0 deletions
|
@ -1807,6 +1807,15 @@ impl ScriptThread {
|
|||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FindElementElementCSS(selector, element_id, reply) => {
|
||||
webdriver_handlers::handle_find_element_element_css(
|
||||
&*documents,
|
||||
pipeline_id,
|
||||
element_id,
|
||||
selector,
|
||||
reply,
|
||||
)
|
||||
},
|
||||
WebDriverScriptCommand::FocusElement(element_id, reply) => {
|
||||
webdriver_handlers::handle_focus_element(
|
||||
&*documents,
|
||||
|
|
|
@ -203,6 +203,23 @@ pub fn handle_find_elements_css(
|
|||
reply.send(node_ids).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_find_element_element_css(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
element_id: String,
|
||||
selector: String,
|
||||
reply: IpcSender<Result<Option<String>, ()>>,
|
||||
) {
|
||||
let node_id = find_node_by_unique_id(documents, pipeline, element_id)
|
||||
.ok_or(())
|
||||
.and_then(|node| {
|
||||
node.query_selector(DOMString::from(selector))
|
||||
.map_err(|_| ())
|
||||
})
|
||||
.map(|node| node.map(|x| x.upcast::<Node>().unique_id()));
|
||||
reply.send(node_id).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_focus_element(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue