зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1388365 - Vendor webdriver 0.29.0. r=whimboo
MozReview-Commit-ID: 3vhk9kfmDHD --HG-- extra : rebase_source : 393c3ff983444bc8639d3ed94edce0b27dabe522
This commit is contained in:
Родитель
a68cdde16c
Коммит
8104c26b91
|
@ -17,7 +17,7 @@ dependencies = [
|
|||
"slog-stdlog 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"slog-stream 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webdriver 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"webdriver 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"zip 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -642,7 +642,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "webdriver"
|
||||
version = "0.28.0"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"backtrace 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -770,7 +770,7 @@ dependencies = [
|
|||
"checksum uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "78c590b5bd79ed10aad8fb75f078a59d8db445af6c743e55c4a53227fc01c13f"
|
||||
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum webdriver 0.28.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9238218a263593f2f143c32d10b0ddec2664a1f9b7be426eb775ee243af44739"
|
||||
"checksum webdriver 0.29.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3aa46482421441f1954f5df7443a66e5744e8de22a3d825262157b109dbdd535"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum winreg 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e63857fb213f619b4c4fff86b158285c76766aac7e7474967e92fb6dbbfeefe9"
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"78252ef89a407b1d76616b7afbf7afb8205530a7f7039f3a7ea140684e3aa8bc","Cargo.toml":"74d24167dc8948953ab5c43b9a524b8ecff667c2f1ce9c0df539c1b799077998","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"bd0e99ce271903a9f67cf5f8fca2f67f2583e4336fbaf583fcd78ec238d4176e","src/capabilities.rs":"5039c1f80885ca2bab19f2d1c40b405c37c09901918625395141ac2e01600728","src/command.rs":"2e60c1b0eabccc3abef91574dbb94a4044a56fc1f4da18a45c6317c726480c2f","src/common.rs":"d696aabe88061f8315578c42115d976123a8fc4276384e478e14d241dfc9acc0","src/error.rs":"b0acf64e052edbc26e7dbcd1a54e8b9a786f01e9d48e0e5b2f410266bfdb9da2","src/httpapi.rs":"8e54ddc2796863ce7d9905484fb8214883a27a33bd94bee2ae765bccb9895f91","src/lib.rs":"336c146e934711dfe49f4b44bbcf278686b00be8d89abb9c7b7b045254994fbf","src/macros.rs":"93094c48e3880d925e684fba9678693eb8c0c39c7ed47b130b0751c4bca37ddc","src/response.rs":"63cabdc7f9136a0f24c10dc16b11c6991c95fd9fee1d1bc47d48c62c6f69eb33","src/server.rs":"f2110378cfaf7a4facb39d0e45c479a00c95a939536c85a6a105c858fffc2d70"},"package":"9238218a263593f2f143c32d10b0ddec2664a1f9b7be426eb775ee243af44739"}
|
||||
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"78252ef89a407b1d76616b7afbf7afb8205530a7f7039f3a7ea140684e3aa8bc","Cargo.toml":"b0f014ae89a79a1923c0209445f65935adf26fabbea19af22a62fc4c51bfb016","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"bd0e99ce271903a9f67cf5f8fca2f67f2583e4336fbaf583fcd78ec238d4176e","src/capabilities.rs":"3ced096444da586e077b0d62fb515f757e7809063e0c65fd7435678c8a8641b3","src/command.rs":"3538491c5e77746eca8d326185903f3336e47f75f69401167acbd655708e736a","src/common.rs":"79d50f6c29f16d370b707988fe7b1747e17372f979df75d30be3e250dce55836","src/error.rs":"7621e0c325c488b537e1bd26dd580b23863bf07bbae52cf8b77e6a7d37df47c3","src/httpapi.rs":"83fec1cefedbadb8bf7458374f909a44ff76d67046e8428fc01067d5d8401dc6","src/lib.rs":"336c146e934711dfe49f4b44bbcf278686b00be8d89abb9c7b7b045254994fbf","src/macros.rs":"93094c48e3880d925e684fba9678693eb8c0c39c7ed47b130b0751c4bca37ddc","src/response.rs":"160bc15135d623d1bc5b33c6edaf69a4034d36c1cd8d9cefb64f436001dda01e","src/server.rs":"4f8976a215783c98f1e3927e5440590fe3a41189bf62fea151434598f904753c"},"package":"3aa46482421441f1954f5df7443a66e5744e8de22a3d825262157b109dbdd535"}
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
[package]
|
||||
name = "webdriver"
|
||||
version = "0.28.0"
|
||||
version = "0.29.0"
|
||||
authors = ["Mozilla Tools and Automation <tools@lists.mozilla.com>"]
|
||||
description = "Library implementing the wire protocol for the W3C WebDriver specification"
|
||||
documentation = "https://docs.rs/webdriver"
|
||||
|
@ -20,14 +20,17 @@ readme = "README.md"
|
|||
keywords = ["webdriver", "browser", "automation", "protocol", "w3c"]
|
||||
license = "MPL-2.0"
|
||||
repository = "https://github.com/mozilla/webdriver-rust"
|
||||
[dependencies.regex]
|
||||
version = "0.2"
|
||||
|
||||
[dependencies.url]
|
||||
version = "1"
|
||||
|
||||
[dependencies.log]
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.backtrace]
|
||||
version = "0.3"
|
||||
|
||||
[dependencies.regex]
|
||||
version = "0.2"
|
||||
[dependencies.hyper]
|
||||
version = "0.10"
|
||||
|
||||
[dependencies.rustc-serialize]
|
||||
version = "0.3"
|
||||
|
@ -39,8 +42,5 @@ default-features = false
|
|||
[dependencies.time]
|
||||
version = "0.1"
|
||||
|
||||
[dependencies.hyper]
|
||||
version = "0.10"
|
||||
|
||||
[dependencies.url]
|
||||
version = "1"
|
||||
[dependencies.backtrace]
|
||||
version = "0.3"
|
||||
|
|
|
@ -149,7 +149,7 @@ impl SpecNewSessionParameters {
|
|||
match &**key {
|
||||
"proxyType" => match value.as_string() {
|
||||
Some("pac") |
|
||||
Some("noproxy") |
|
||||
Some("direct") |
|
||||
Some("autodetect") |
|
||||
Some("system") |
|
||||
Some("manual") => {},
|
||||
|
|
|
@ -9,7 +9,7 @@ use rustc_serialize::json::{ToJson, Json};
|
|||
use std::collections::BTreeMap;
|
||||
use std::default::Default;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum WebDriverCommand<T: WebDriverExtensionCommand> {
|
||||
NewSession(NewSessionParameters),
|
||||
DeleteSession,
|
||||
|
@ -74,7 +74,7 @@ pub trait WebDriverExtensionCommand : Clone + Send + PartialEq {
|
|||
fn parameters_json(&self) -> Option<Json>;
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VoidWebDriverExtensionCommand;
|
||||
|
||||
impl WebDriverExtensionCommand for VoidWebDriverExtensionCommand {
|
||||
|
@ -83,7 +83,7 @@ impl WebDriverExtensionCommand for VoidWebDriverExtensionCommand {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct WebDriverMessage <U: WebDriverExtensionRoute=VoidWebDriverExtensionRoute> {
|
||||
pub session_id: Option<String>,
|
||||
pub command: WebDriverCommand<U::Command>,
|
||||
|
@ -490,7 +490,7 @@ impl CapabilitiesMatching for NewSessionParameters {
|
|||
}
|
||||
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct GetParameters {
|
||||
pub url: String
|
||||
}
|
||||
|
@ -519,7 +519,7 @@ impl ToJson for GetParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct TimeoutsParameters {
|
||||
pub script: Option<u64>,
|
||||
pub page_load: Option<u64>,
|
||||
|
@ -658,7 +658,7 @@ impl ToJson for WindowRectParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SwitchToWindowParameters {
|
||||
pub handle: String
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ impl ToJson for SwitchToWindowParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct LocatorParameters {
|
||||
pub using: LocatorStrategy,
|
||||
pub value: String
|
||||
|
@ -726,7 +726,7 @@ impl ToJson for LocatorParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SwitchToFrameParameters {
|
||||
pub id: FrameId
|
||||
}
|
||||
|
@ -754,7 +754,7 @@ impl ToJson for SwitchToFrameParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SendKeysParameters {
|
||||
pub text: String
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ impl ToJson for SendKeysParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct JavascriptCommandParameters {
|
||||
pub script: String,
|
||||
pub args: Nullable<Vec<Json>>
|
||||
|
@ -832,7 +832,7 @@ impl ToJson for JavascriptCommandParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct GetNamedCookieParameters {
|
||||
pub name: Nullable<String>,
|
||||
}
|
||||
|
@ -863,7 +863,7 @@ impl ToJson for GetNamedCookieParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct AddCookieParameters {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
|
@ -978,7 +978,7 @@ impl ToJson for AddCookieParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct TakeScreenshotParameters {
|
||||
pub element: Nullable<WebElement>
|
||||
}
|
||||
|
@ -1011,7 +1011,7 @@ impl ToJson for TakeScreenshotParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ActionsParameters {
|
||||
pub actions: Vec<ActionSequence>
|
||||
}
|
||||
|
@ -1047,7 +1047,7 @@ impl ToJson for ActionsParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ActionSequence {
|
||||
pub id: Nullable<String>,
|
||||
pub actions: ActionsType
|
||||
|
@ -1113,7 +1113,7 @@ impl ToJson for ActionSequence {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ActionsType {
|
||||
Null(Vec<NullActionItem>),
|
||||
Key(Vec<KeyActionItem>),
|
||||
|
@ -1162,7 +1162,7 @@ impl Parameters for ActionsType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerType {
|
||||
Mouse,
|
||||
Pen,
|
||||
|
@ -1203,7 +1203,7 @@ impl Default for PointerType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub struct PointerActionParameters {
|
||||
pub pointer_type: PointerType
|
||||
}
|
||||
|
@ -1232,7 +1232,7 @@ impl ToJson for PointerActionParameters {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum NullActionItem {
|
||||
General(GeneralAction)
|
||||
}
|
||||
|
@ -1265,7 +1265,7 @@ impl ToJson for NullActionItem {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum KeyActionItem {
|
||||
General(GeneralAction),
|
||||
Key(KeyAction)
|
||||
|
@ -1300,7 +1300,7 @@ impl ToJson for KeyActionItem {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerActionItem {
|
||||
General(GeneralAction),
|
||||
Pointer(PointerAction)
|
||||
|
@ -1334,7 +1334,7 @@ impl ToJson for PointerActionItem {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum GeneralAction {
|
||||
Pause(PauseAction)
|
||||
}
|
||||
|
@ -1357,7 +1357,7 @@ impl ToJson for GeneralAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PauseAction {
|
||||
pub duration: u64
|
||||
}
|
||||
|
@ -1384,7 +1384,7 @@ impl ToJson for PauseAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum KeyAction {
|
||||
Up(KeyUpAction),
|
||||
Down(KeyDownAction)
|
||||
|
@ -1427,7 +1427,7 @@ fn validate_key_value(value_str: &str) -> WebDriverResult<char> {
|
|||
Ok(value)
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct KeyUpAction {
|
||||
pub value: char
|
||||
}
|
||||
|
@ -1459,7 +1459,7 @@ impl ToJson for KeyUpAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct KeyDownAction {
|
||||
pub value: char
|
||||
}
|
||||
|
@ -1490,7 +1490,7 @@ impl ToJson for KeyDownAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerOrigin {
|
||||
Viewport,
|
||||
Pointer,
|
||||
|
@ -1531,7 +1531,7 @@ impl Default for PointerOrigin {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum PointerAction {
|
||||
Up(PointerUpAction),
|
||||
Down(PointerDownAction),
|
||||
|
@ -1569,7 +1569,7 @@ impl ToJson for PointerAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PointerUpAction {
|
||||
pub button: u64,
|
||||
}
|
||||
|
@ -1599,7 +1599,7 @@ impl ToJson for PointerUpAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PointerDownAction {
|
||||
pub button: u64,
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ impl ToJson for PointerDownAction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct PointerMoveAction {
|
||||
pub duration: Nullable<u64>,
|
||||
pub origin: PointerOrigin,
|
||||
|
|
|
@ -6,7 +6,7 @@ use error::{WebDriverResult, WebDriverError, ErrorStatus};
|
|||
|
||||
pub static ELEMENT_KEY: &'static str = "element-6066-11e4-a52e-4f735466cecf";
|
||||
|
||||
#[derive(RustcEncodable, PartialEq, Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
|
||||
pub struct Date(pub u64);
|
||||
|
||||
impl Date {
|
||||
|
@ -22,7 +22,7 @@ impl ToJson for Date {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Nullable<T: ToJson> {
|
||||
Value(T),
|
||||
Null
|
||||
|
@ -142,7 +142,7 @@ impl <T> From<T> for WebElement
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum FrameId {
|
||||
Short(u16),
|
||||
Element(WebElement),
|
||||
|
@ -184,19 +184,19 @@ impl ToJson for FrameId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum LocatorStrategy {
|
||||
CSSSelector,
|
||||
LinkText,
|
||||
PartialLinkText,
|
||||
XPath
|
||||
XPath,
|
||||
}
|
||||
|
||||
impl LocatorStrategy {
|
||||
pub fn from_json(body: &Json) -> WebDriverResult<LocatorStrategy> {
|
||||
match try_opt!(body.as_string(),
|
||||
ErrorStatus::InvalidArgument,
|
||||
"Cound not convert strategy to string") {
|
||||
"Expected locator strategy as string") {
|
||||
"css selector" => Ok(LocatorStrategy::CSSSelector),
|
||||
"link text" => Ok(LocatorStrategy::LinkText),
|
||||
"partial link text" => Ok(LocatorStrategy::PartialLinkText),
|
||||
|
@ -217,3 +217,55 @@ impl ToJson for LocatorStrategy {
|
|||
}.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
/// The top-level browsing context has an associated window state which
|
||||
/// describes what visibility state its OS widget window is in.
|
||||
///
|
||||
/// The default state is [`Normal`].
|
||||
///
|
||||
/// [`normal`]: #variant.Normal
|
||||
#[derive(Debug)]
|
||||
pub enum WindowState {
|
||||
/// The window is maximized.
|
||||
Maximized,
|
||||
/// The window is iconified.
|
||||
Minimized,
|
||||
/// The window is shown normally.
|
||||
Normal,
|
||||
/// The window is in full screen mode.
|
||||
Fullscreen,
|
||||
}
|
||||
|
||||
impl WindowState {
|
||||
pub fn from_json(body: &Json) -> WebDriverResult<WindowState> {
|
||||
use self::WindowState::*;
|
||||
let s = try_opt!(
|
||||
body.as_string(),
|
||||
ErrorStatus::InvalidArgument,
|
||||
"Expecetd window state as string"
|
||||
);
|
||||
match s {
|
||||
"maximized" => Ok(Maximized),
|
||||
"minimized" => Ok(Minimized),
|
||||
"normal" => Ok(Normal),
|
||||
"fullscreen" => Ok(Fullscreen),
|
||||
x => Err(WebDriverError::new(
|
||||
ErrorStatus::InvalidArgument,
|
||||
format!("Unknown window state {}", x),
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for WindowState {
|
||||
fn to_json(&self) -> Json {
|
||||
use self::WindowState::*;
|
||||
let state = match *self {
|
||||
Maximized => "maximized",
|
||||
Minimized => "minimized",
|
||||
Normal => "normal",
|
||||
Fullscreen => "fullscreen",
|
||||
};
|
||||
Json::String(state.to_string())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::error::Error;
|
|||
use std::fmt;
|
||||
use std::io;
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum ErrorStatus {
|
||||
/// The [`ElementClick`] command could not be completed because the
|
||||
/// [element] receiving the events is obscuring the element that was
|
||||
|
|
|
@ -71,7 +71,7 @@ fn standard_routes<U:WebDriverExtensionRoute>() -> Vec<(Method, &'static str, Ro
|
|||
(Get, "/status", Route::Status),]
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum Route<U:WebDriverExtensionRoute> {
|
||||
NewSession,
|
||||
DeleteSession,
|
||||
|
@ -142,7 +142,7 @@ pub trait WebDriverExtensionRoute : Clone + Send + PartialEq {
|
|||
fn command(&self, &Captures, &Json) -> WebDriverResult<WebDriverCommand<Self::Command>>;
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct VoidWebDriverExtensionRoute;
|
||||
|
||||
impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
|
||||
|
@ -153,7 +153,7 @@ impl WebDriverExtensionRoute for VoidWebDriverExtensionRoute {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
struct RequestMatcher<U: WebDriverExtensionRoute> {
|
||||
method: Method,
|
||||
path_regexp: Regex,
|
||||
|
@ -197,6 +197,7 @@ impl <U: WebDriverExtensionRoute> RequestMatcher<U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WebDriverHttpApi<U: WebDriverExtensionRoute> {
|
||||
routes: Vec<(Method, RequestMatcher<U>)>,
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use rustc_serialize::json::{self, Json, ToJson};
|
||||
|
||||
use common::{Nullable, Date};
|
||||
use common::{Date, Nullable, WindowState};
|
||||
use cookie;
|
||||
use rustc_serialize::json::{self, Json, ToJson};
|
||||
use std::collections::BTreeMap;
|
||||
use time;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -10,12 +10,12 @@ pub enum WebDriverResponse {
|
|||
Cookie(CookieResponse),
|
||||
Cookies(CookiesResponse),
|
||||
DeleteSession,
|
||||
ElementRect(RectResponse),
|
||||
ElementRect(ElementRectResponse),
|
||||
Generic(ValueResponse),
|
||||
NewSession(NewSessionResponse),
|
||||
Timeouts(TimeoutsResponse),
|
||||
Void,
|
||||
WindowRect(RectResponse),
|
||||
WindowRect(WindowRectResponse),
|
||||
}
|
||||
|
||||
impl WebDriverResponse {
|
||||
|
@ -32,7 +32,7 @@ impl WebDriverResponse {
|
|||
NewSession(ref x) => json::encode(x),
|
||||
Timeouts(ref x) => json::encode(x),
|
||||
Void => Ok("{}".to_string()),
|
||||
WindowRect(ref x) => json::encode(x),
|
||||
WindowRect(ref x) => json::encode(&x.to_json()),
|
||||
}.unwrap();
|
||||
|
||||
match self {
|
||||
|
@ -48,7 +48,7 @@ impl WebDriverResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct CloseWindowResponse {
|
||||
pub window_handles: Vec<String>,
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ impl ToJson for CloseWindowResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct NewSessionResponse {
|
||||
pub sessionId: String,
|
||||
pub capabilities: json::Json
|
||||
|
@ -83,7 +83,7 @@ impl NewSessionResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct TimeoutsResponse {
|
||||
pub script: u64,
|
||||
pub pageLoad: u64,
|
||||
|
@ -100,7 +100,7 @@ impl TimeoutsResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct ValueResponse {
|
||||
pub value: json::Json
|
||||
}
|
||||
|
@ -113,26 +113,70 @@ impl ValueResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
pub struct RectResponse {
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct ElementRectResponse {
|
||||
/// X axis position of the top-left corner of the element relative
|
||||
// to the current browsing context’s document element in CSS reference
|
||||
// pixels.
|
||||
pub x: f64,
|
||||
|
||||
/// Y axis position of the top-left corner of the element relative
|
||||
// to the current browsing context’s document element in CSS reference
|
||||
// pixels.
|
||||
pub y: f64,
|
||||
|
||||
/// Height of the element’s [bounding rectangle] in CSS reference
|
||||
/// pixels.
|
||||
///
|
||||
/// [bounding rectangle]: https://drafts.fxtf.org/geometry/#rectangle
|
||||
pub width: f64,
|
||||
pub height: f64
|
||||
|
||||
/// Width of the element’s [bounding rectangle] in CSS reference
|
||||
/// pixels.
|
||||
///
|
||||
/// [bounding rectangle]: https://drafts.fxtf.org/geometry/#rectangle
|
||||
pub height: f64,
|
||||
}
|
||||
|
||||
impl RectResponse {
|
||||
pub fn new(x: f64, y: f64, width: f64, height: f64) -> RectResponse {
|
||||
RectResponse {
|
||||
x: x,
|
||||
y: y,
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct WindowRectResponse {
|
||||
/// `WindowProxy`’s [screenX] attribute.
|
||||
///
|
||||
/// [screenX]: https://drafts.csswg.org/cssom-view/#dom-window-screenx
|
||||
pub x: f64,
|
||||
|
||||
/// `WindowProxy`’s [screenY] attribute.
|
||||
///
|
||||
/// [screenY]: https://drafts.csswg.org/cssom-view/#dom-window-screeny
|
||||
pub y: f64,
|
||||
|
||||
/// Width of the top-level browsing context’s outer dimensions, including
|
||||
/// any browser chrome and externally drawn window decorations in CSS
|
||||
/// reference pixels.
|
||||
pub width: f64,
|
||||
|
||||
/// Height of the top-level browsing context’s outer dimensions, including
|
||||
/// any browser chrome and externally drawn window decorations in CSS
|
||||
/// reference pixels.
|
||||
pub height: f64,
|
||||
|
||||
/// The top-level browsing context’s window state.
|
||||
pub state: WindowState,
|
||||
}
|
||||
|
||||
impl ToJson for WindowRectResponse {
|
||||
fn to_json(&self) -> Json {
|
||||
let mut body = BTreeMap::new();
|
||||
body.insert("x".to_owned(), self.x.to_json());
|
||||
body.insert("y".to_owned(), self.y.to_json());
|
||||
body.insert("width".to_owned(), self.width.to_json());
|
||||
body.insert("height".to_owned(), self.height.to_json());
|
||||
body.insert("state".to_owned(), self.state.to_json());
|
||||
Json::Object(body)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, PartialEq, Debug, Clone)]
|
||||
#[derive(Clone, Debug, PartialEq, RustcEncodable)]
|
||||
pub struct Cookie {
|
||||
pub name: String,
|
||||
pub value: String,
|
||||
|
@ -166,20 +210,22 @@ impl Into<cookie::Cookie<'static>> for Cookie {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct CookieResponse {
|
||||
pub value: Cookie,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable, Debug)]
|
||||
#[derive(Debug, RustcEncodable)]
|
||||
pub struct CookiesResponse {
|
||||
pub value: Vec<Cookie>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{CloseWindowResponse, Cookie, CookieResponse, CookiesResponse, NewSessionResponse,
|
||||
Nullable, RectResponse, TimeoutsResponse, ValueResponse, WebDriverResponse};
|
||||
use super::{CloseWindowResponse, Cookie, CookieResponse, CookiesResponse, ElementRectResponse,
|
||||
NewSessionResponse, Nullable, TimeoutsResponse, ValueResponse, WebDriverResponse,
|
||||
WindowRectResponse};
|
||||
use common::WindowState;
|
||||
use rustc_serialize::json::Json;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
|
@ -236,21 +282,28 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_element_rect() {
|
||||
let resp = WebDriverResponse::ElementRect(RectResponse::new(
|
||||
0f64, 1f64, 2f64, 3f64));
|
||||
let rect = ElementRectResponse {
|
||||
x: 0f64,
|
||||
y: 1f64,
|
||||
width: 2f64,
|
||||
height: 3f64,
|
||||
};
|
||||
let resp = WebDriverResponse::ElementRect(rect);
|
||||
let expected = r#"{"value": {"x": 0.0, "y": 1.0, "width": 2.0, "height": 3.0}}"#;
|
||||
test(resp, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_window_rect() {
|
||||
let resp = WebDriverResponse::WindowRect(RectResponse {
|
||||
let rect = WindowRectResponse {
|
||||
x: 0f64,
|
||||
y: 1f64,
|
||||
width: 2f64,
|
||||
height: 3f64,
|
||||
});
|
||||
let expected = r#"{"value": {"x": 0.0, "y": 1.0, "width": 2.0, "height": 3.0}}"#;
|
||||
state: WindowState::Normal,
|
||||
};
|
||||
let resp = WebDriverResponse::WindowRect(rect);
|
||||
let expected = r#"{"value": {"x": 0.0, "y": 1.0, "width": 2.0, "height": 3.0, "state": "normal"}}"#;
|
||||
test(resp, expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ enum DispatchMessage<U: WebDriverExtensionRoute> {
|
|||
Quit
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Session {
|
||||
id: String
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ pub trait WebDriverHandler<U: WebDriverExtensionRoute=VoidWebDriverExtensionRout
|
|||
fn delete_session(&mut self, session: &Option<Session>);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Dispatcher<T: WebDriverHandler<U>,
|
||||
U: WebDriverExtensionRoute> {
|
||||
handler: T,
|
||||
|
@ -148,6 +149,7 @@ impl<T: WebDriverHandler<U>, U: WebDriverExtensionRoute> Dispatcher<T, U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct HttpHandler<U: WebDriverExtensionRoute> {
|
||||
chan: Mutex<Sender<DispatchMessage<U>>>,
|
||||
api: Mutex<WebDriverHttpApi<U>>
|
||||
|
|
Загрузка…
Ссылка в новой задаче