aboutsummaryrefslogtreecommitdiffstats
path: root/components/webdriver_server/lib.rs
diff options
context:
space:
mode:
authorJames Graham <james@hoppipolla.co.uk>2015-10-23 00:48:55 +0100
committerJames Graham <james@hoppipolla.co.uk>2015-11-20 13:23:38 +0000
commitf7258e4fccf9b7f8efc4b3a33203cacfe47d647a (patch)
tree32a54e8f5a8e4df247c36747a5af077807e86ad6 /components/webdriver_server/lib.rs
parent0146751bb227e577f54c4c0574ae36236e2bcdce (diff)
downloadservo-f7258e4fccf9b7f8efc4b3a33203cacfe47d647a.tar.gz
servo-f7258e4fccf9b7f8efc4b3a33203cacfe47d647a.zip
Add support for getting an element's computed style through WebDriver.
Diffstat (limited to 'components/webdriver_server/lib.rs')
-rw-r--r--components/webdriver_server/lib.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs
index 2abdb562114..9bad724d164 100644
--- a/components/webdriver_server/lib.rs
+++ b/components/webdriver_server/lib.rs
@@ -539,6 +539,20 @@ impl Handler {
}
}
+ fn handle_element_css(&self, element: &WebElement, name: &String) -> WebDriverResult<WebDriverResponse> {
+ let pipeline_id = try!(self.frame_pipeline());
+
+ let (sender, receiver) = ipc::channel().unwrap();
+ let cmd = WebDriverScriptCommand::GetElementCSS(element.id.clone(), name.clone(), sender);
+ let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
+ self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
+ match receiver.recv().unwrap() {
+ Ok(value) => Ok(WebDriverResponse::Generic(ValueResponse::new(value.to_json()))),
+ Err(_) => Err(WebDriverError::new(ErrorStatus::StaleElementReference,
+ "Unable to find element in document"))
+ }
+ }
+
fn handle_set_timeouts(&mut self, parameters: &TimeoutsParameters) -> WebDriverResult<WebDriverResponse> {
//TODO: this conversion is crazy, spec should limit these to u32 and check upstream
let value = parameters.ms as u32;
@@ -731,6 +745,8 @@ impl WebDriverHandler<ServoExtensionRoute> for Handler {
WebDriverCommand::GetElementTagName(ref element) => self.handle_element_tag_name(element),
WebDriverCommand::GetElementAttribute(ref element, ref name) =>
self.handle_element_attribute(element, name),
+ WebDriverCommand::GetCSSValue(ref element, ref name) =>
+ self.handle_element_css(element, name),
WebDriverCommand::ExecuteScript(ref x) => self.handle_execute_script(x),
WebDriverCommand::ExecuteAsyncScript(ref x) => self.handle_execute_async_script(x),
WebDriverCommand::ElementSendKeys(ref element, ref keys) =>