mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #8564 - jgraham:webdriver_attr, r=Ms2ger
Implement Get Element Attribute WebDriver command This intentionally doesn't implement the special handling for boolean attributes yet, since that requires some kind of exhaustive list of all such attributes <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8564) <!-- Reviewable:end -->
This commit is contained in:
commit
7f95693288
4 changed files with 35 additions and 0 deletions
|
@ -1092,6 +1092,8 @@ impl ScriptTask {
|
|||
webdriver_handlers::handle_get_active_element(&page, pipeline_id, reply),
|
||||
WebDriverScriptCommand::GetElementTagName(node_id, reply) =>
|
||||
webdriver_handlers::handle_get_name(&page, pipeline_id, node_id, reply),
|
||||
WebDriverScriptCommand::GetElementAttribute(node_id, name, reply) =>
|
||||
webdriver_handlers::handle_get_attribute(&page, pipeline_id, node_id, name, reply),
|
||||
WebDriverScriptCommand::GetElementText(node_id, reply) =>
|
||||
webdriver_handlers::handle_get_text(&page, pipeline_id, node_id, reply),
|
||||
WebDriverScriptCommand::GetFrameId(frame_id, reply) =>
|
||||
|
|
|
@ -203,6 +203,21 @@ pub fn handle_get_name(page: &Rc<Page>,
|
|||
}).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_get_attribute(page: &Rc<Page>,
|
||||
pipeline: PipelineId,
|
||||
node_id: String,
|
||||
name: String,
|
||||
reply: IpcSender<Result<Option<String>, ()>>) {
|
||||
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
|
||||
Some(node) => {
|
||||
Ok(node.downcast::<Element>().unwrap().GetAttribute(DOMString::from(name))
|
||||
.map(String::from))
|
||||
},
|
||||
None => Err(())
|
||||
}).unwrap();
|
||||
}
|
||||
|
||||
|
||||
pub fn handle_get_url(page: &Rc<Page>,
|
||||
_pipeline: PipelineId,
|
||||
reply: IpcSender<Url>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue