Move webdriver_msg to script_traits.

This commit is contained in:
Ms2ger 2016-07-04 14:45:29 +02:00
parent b8fe9e9637
commit 77caf83098
12 changed files with 20 additions and 22 deletions

View file

@ -11,6 +11,7 @@ path = "lib.rs"
[dependencies]
app_units = "0.2.5"
canvas_traits = {path = "../canvas_traits"}
cookie = { version = "0.2.5", features = ["serialize-rustc", "serialize-serde"]}
devtools_traits = {path = "../devtools_traits"}
euclid = "0.7.1"
gfx_traits = {path = "../gfx_traits"}
@ -24,6 +25,7 @@ net_traits = {path = "../net_traits"}
offscreen_gl_context = "0.1.2"
plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"}
rustc-serialize = "0.3.4"
serde = "0.7.11"
serde_macros = "0.7.11"
style_traits = {path = "../style_traits", features = ["servo"]}

View file

@ -13,6 +13,7 @@
extern crate app_units;
extern crate canvas_traits;
extern crate cookie as cookie_rs;
extern crate devtools_traits;
extern crate euclid;
extern crate gfx_traits;
@ -24,6 +25,7 @@ extern crate msg;
extern crate net_traits;
extern crate offscreen_gl_context;
extern crate profile_traits;
extern crate rustc_serialize;
extern crate serde;
extern crate style_traits;
extern crate time;
@ -31,6 +33,7 @@ extern crate url;
extern crate util;
mod script_msg;
pub mod webdriver_msg;
use app_units::Au;
use devtools_traits::ScriptToDevtoolsControlMsg;
@ -50,7 +53,6 @@ use libc::c_void;
use msg::constellation_msg::{FrameId, FrameType, Image, Key, KeyModifiers, KeyState, LoadData};
use msg::constellation_msg::{NavigationDirection, PanicMsg, PipelineId};
use msg::constellation_msg::{PipelineNamespaceId, SubpageId, WindowSizeType};
use msg::webdriver_msg::{LoadStatus, WebDriverScriptCommand};
use net_traits::ResourceThreads;
use net_traits::bluetooth_thread::BluetoothMethodMsg;
use net_traits::image_cache_thread::ImageCacheThread;
@ -62,6 +64,7 @@ use std::sync::mpsc::{Sender, Receiver};
use url::Url;
use util::geometry::{PagePx, ViewportPx};
use util::ipc::OptionalOpaqueIpcSender;
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
pub use script_msg::{LayoutMsg, ScriptMsg, EventResult};

View file

@ -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
}