/* 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; use hyper_serde::Serde; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::BrowsingContextId; use rustc_serialize::json::{Json, ToJson}; use servo_url::ServoUrl; #[derive(Deserialize, Serialize)] pub enum WebDriverScriptCommand { AddCookie(#[serde(deserialize_with = "::hyper_serde::deserialize", serialize_with = "::hyper_serde::serialize")] Cookie<'static>, IpcSender>), ExecuteScript(String, IpcSender), ExecuteAsyncScript(String, IpcSender), FindElementCSS(String, IpcSender, ()>>), FindElementsCSS(String, IpcSender, ()>>), FocusElement(String, IpcSender>), GetActiveElement(IpcSender>), GetCookie(String, IpcSender>>>), GetCookies(IpcSender>>>), GetElementAttribute(String, String, IpcSender, ()>>), GetElementCSS(String, String, IpcSender>), GetElementRect(String, IpcSender, ()>>), GetElementTagName(String, IpcSender>), GetElementText(String, IpcSender>), GetBrowsingContextId(WebDriverFrameId, IpcSender>), GetUrl(IpcSender), IsEnabled(String, IpcSender>), IsSelected(String, IpcSender>), GetTitle(IpcSender), } #[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, /// Occurs when handler received an event message for a layout channel that is not /// associated with the current script thread BrowsingContextNotFound, } pub type WebDriverJSResult = Result; #[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, }