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:
bors-servo 2015-11-19 23:16:25 +05:30
commit 7f95693288
4 changed files with 35 additions and 0 deletions

View file

@ -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) =>

View file

@ -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>) {