mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #8151 - jgraham:webdriver_sendkeys, r=jgraham
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. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8151) <!-- Reviewable:end -->
This commit is contained in:
commit
afe03870ce
7 changed files with 252 additions and 2 deletions
|
@ -1086,6 +1086,8 @@ impl ScriptTask {
|
|||
webdriver_handlers::handle_find_element_css(&page, pipeline_id, selector, reply),
|
||||
WebDriverScriptCommand::FindElementsCSS(selector, reply) =>
|
||||
webdriver_handlers::handle_find_elements_css(&page, pipeline_id, selector, reply),
|
||||
WebDriverScriptCommand::FocusElement(element_id, reply) =>
|
||||
webdriver_handlers::handle_focus_element(&page, pipeline_id, element_id, reply),
|
||||
WebDriverScriptCommand::GetActiveElement(reply) =>
|
||||
webdriver_handlers::handle_get_active_element(&page, pipeline_id, reply),
|
||||
WebDriverScriptCommand::GetElementTagName(node_id, reply) =>
|
||||
|
|
|
@ -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>>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue