diff options
author | James Graham <james@hoppipolla.co.uk> | 2015-06-16 17:32:42 +0100 |
---|---|---|
committer | James Graham <james@hoppipolla.co.uk> | 2015-11-16 22:48:26 +0000 |
commit | 09b9293b092a89aaca651f3ce655e5a97878e52c (patch) | |
tree | 67cf816cd300717b8d5c8d3d364680db1ce230e9 /components/script/webdriver_handlers.rs | |
parent | db94fda10e3351c96a0df61099d2fdfa481cc62b (diff) | |
download | servo-09b9293b092a89aaca651f3ce655e5a97878e52c.tar.gz servo-09b9293b092a89aaca651f3ce655e5a97878e52c.zip |
Implement support for WebDriver send keys command.
Supports sending keys to an element. The specification here is still
rather unfinished so the error handling and so on in this code will
need iteration as it becomes clearer what the expected behaviour is.
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r-- | components/script/webdriver_handlers.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 8a2385ae0f4..cd49c8126f7 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -4,6 +4,7 @@ use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; +use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; @@ -11,6 +12,7 @@ use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior}; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::element::Element; +use dom::htmlelement::HTMLElement; use dom::htmliframeelement::HTMLIFrameElement; use dom::node::Node; use dom::window::ScriptHelpers; @@ -147,6 +149,25 @@ pub fn handle_find_elements_css(page: &Rc<Page>, }).unwrap(); } +pub fn handle_focus_element(page: &Rc<Page>, + pipeline: PipelineId, + element_id: String, + reply: IpcSender<Result<(), ()>>) { + reply.send(match find_node_by_unique_id(page, pipeline, element_id) { + Some(ref node) => { + match node.downcast::<HTMLElement>() { + Some(ref elem) => { + // Need a way to find if this actually succeeded + elem.Focus(); + Ok(()) + } + None => Err(()) + } + }, + None => Err(()) + }).unwrap(); +} + pub fn handle_get_active_element(page: &Rc<Page>, _pipeline: PipelineId, reply: IpcSender<Option<String>>) { |