aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2015-11-19 23:16:25 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2015-11-19 23:16:25 +0530
commit7f95693288eac546b7b31a51a6fcf80883ae533b (patch)
tree3b11e1b2d5afcd24415fd6b23a66b161f362efa9 /components/script
parentced8763b25df54f7820563200003dd79c05d0ec3 (diff)
parent6446cc3db8ae42c6a24498ddd2293d271c204753 (diff)
downloadservo-7f95693288eac546b7b31a51a6fcf80883ae533b.tar.gz
servo-7f95693288eac546b7b31a51a6fcf80883ae533b.zip
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 -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/script_task.rs2
-rw-r--r--components/script/webdriver_handlers.rs15
2 files changed, 17 insertions, 0 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 5a12d9e004f..5f881601bd7 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -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) =>
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index cd49c8126f7..0bf2ede1aeb 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -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>) {