diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-05 00:58:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-05 00:58:51 -0700 |
commit | 181261004d3b217605cb2d8fbdc00ad0785532ba (patch) | |
tree | 61bdd8a45d48704ab8ca2dbfac38ed792d7413a7 /components/script_traits/webdriver_msg.rs | |
parent | e3eeb643f0b64107bcec01c9075f8bd9cefe58b3 (diff) | |
parent | 77caf83098baf8a9157d388442abcd243eb5825c (diff) | |
download | servo-181261004d3b217605cb2d8fbdc00ad0785532ba.tar.gz servo-181261004d3b217605cb2d8fbdc00ad0785532ba.zip |
Auto merge of #12216 - servo:msg, r=jdm
Move some types from msg to script_traits.
<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12216)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script_traits/webdriver_msg.rs')
-rw-r--r-- | components/script_traits/webdriver_msg.rs | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/components/script_traits/webdriver_msg.rs b/components/script_traits/webdriver_msg.rs new file mode 100644 index 00000000000..0694c97f29d --- /dev/null +++ b/components/script_traits/webdriver_msg.rs @@ -0,0 +1,84 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#![allow(missing_docs)] + +use cookie_rs::Cookie; +use euclid::rect::Rect; +use ipc_channel::ipc::IpcSender; +use msg::constellation_msg::PipelineId; +use rustc_serialize::json::{Json, ToJson}; +use url::Url; + +#[derive(Deserialize, Serialize)] +pub enum WebDriverScriptCommand { + AddCookie(Cookie, IpcSender<Result<(), WebDriverCookieError>>), + ExecuteScript(String, IpcSender<WebDriverJSResult>), + ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>), + FindElementCSS(String, IpcSender<Result<Option<String>, ()>>), + FindElementsCSS(String, IpcSender<Result<Vec<String>, ()>>), + FocusElement(String, IpcSender<Result<(), ()>>), + GetActiveElement(IpcSender<Option<String>>), + GetCookie(String, IpcSender<Vec<Cookie>>), + GetCookies(IpcSender<Vec<Cookie>>), + GetElementAttribute(String, String, IpcSender<Result<Option<String>, ()>>), + GetElementCSS(String, String, IpcSender<Result<String, ()>>), + GetElementRect(String, IpcSender<Result<Rect<f64>, ()>>), + GetElementTagName(String, IpcSender<Result<String, ()>>), + GetElementText(String, IpcSender<Result<String, ()>>), + GetFrameId(WebDriverFrameId, IpcSender<Result<Option<PipelineId>, ()>>), + GetUrl(IpcSender<Url>), + IsEnabled(String, IpcSender<Result<bool, ()>>), + IsSelected(String, IpcSender<Result<bool, ()>>), + GetTitle(IpcSender<String>) +} + +#[derive(Deserialize, Serialize)] +pub enum WebDriverCookieError { + InvalidDomain, + UnableToSetCookie +} + +#[derive(Deserialize, Serialize)] +pub enum WebDriverJSValue { + Undefined, + Null, + Boolean(bool), + Number(f64), + String(String), + // TODO: Object and WebElement +} + +#[derive(Deserialize, Serialize)] +pub enum WebDriverJSError { + Timeout, + UnknownType +} + +pub type WebDriverJSResult = Result<WebDriverJSValue, WebDriverJSError>; + +#[derive(Deserialize, Serialize)] +pub enum WebDriverFrameId { + Short(u16), + Element(String), + Parent +} + +impl ToJson for WebDriverJSValue { + fn to_json(&self) -> Json { + match *self { + WebDriverJSValue::Undefined => Json::Null, + WebDriverJSValue::Null => Json::Null, + WebDriverJSValue::Boolean(ref x) => x.to_json(), + WebDriverJSValue::Number(ref x) => x.to_json(), + WebDriverJSValue::String(ref x) => x.to_json() + } + } +} + +#[derive(Deserialize, Serialize)] +pub enum LoadStatus { + LoadComplete, + LoadTimeout +} |