mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1569100 - Add SetTimeouts command to Marionette. r=ato
Differential Revision: https://phabricator.services.mozilla.com/D39662 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
141bcffcc8
commit
417c0e949d
@ -20,9 +20,15 @@ pub struct WebElement {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Timeouts {
|
pub struct Timeouts {
|
||||||
pub implicit: u64,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
#[serde(rename = "pageLoad", alias = "page load")]
|
pub implicit: Option<u64>,
|
||||||
pub page_load: u64,
|
#[serde(
|
||||||
|
rename = "pageLoad",
|
||||||
|
alias = "page load",
|
||||||
|
skip_serializing_if = "Option::is_none"
|
||||||
|
)]
|
||||||
|
pub page_load: Option<u64>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub script: Option<u64>,
|
pub script: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +47,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_timeouts() {
|
fn test_timeouts_with_all_params() {
|
||||||
let data = Timeouts {
|
let data = Timeouts {
|
||||||
implicit: 1000,
|
implicit: Some(1000),
|
||||||
page_load: 200000,
|
page_load: Some(200000),
|
||||||
script: Some(60000),
|
script: Some(60000),
|
||||||
};
|
};
|
||||||
assert_ser_de(
|
assert_ser_de(
|
||||||
@ -56,4 +62,14 @@ mod tests {
|
|||||||
json!({"implicit":1000,"page load":200000,"script":60000}),
|
json!({"implicit":1000,"page load":200000,"script":60000}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_timeouts_with_missing_params() {
|
||||||
|
let data = Timeouts {
|
||||||
|
implicit: Some(1000),
|
||||||
|
page_load: None,
|
||||||
|
script: None,
|
||||||
|
};
|
||||||
|
assert_ser_de(&data, json!({"implicit":1000}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ use crate::common::{Timeouts, WebElement};
|
|||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum MarionetteResult {
|
pub enum MarionetteResult {
|
||||||
|
#[serde(deserialize_with = "from_value", serialize_with = "to_empty_value")]
|
||||||
|
Null,
|
||||||
#[serde(deserialize_with = "from_value", serialize_with = "to_value")]
|
#[serde(deserialize_with = "from_value", serialize_with = "to_value")]
|
||||||
String(String),
|
String(String),
|
||||||
Timeouts(Timeouts),
|
|
||||||
#[serde(deserialize_with = "from_value", serialize_with = "to_value")]
|
#[serde(deserialize_with = "from_value", serialize_with = "to_value")]
|
||||||
WebElement(WebElement),
|
WebElement(WebElement),
|
||||||
WebElements(Vec<WebElement>),
|
WebElements(Vec<WebElement>),
|
||||||
#[serde(deserialize_with = "from_value", serialize_with = "to_empty_value")]
|
Timeouts(Timeouts),
|
||||||
Null,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_value<T, S>(data: T, serializer: S) -> Result<S::Ok, S::Error>
|
fn to_value<T, S>(data: T, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@ -91,8 +91,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_timeouts_response() {
|
fn test_timeouts_response() {
|
||||||
let data = Timeouts {
|
let data = Timeouts {
|
||||||
implicit: 1000,
|
implicit: Some(1000),
|
||||||
page_load: 200000,
|
page_load: Some(200000),
|
||||||
script: Some(60000),
|
script: Some(60000),
|
||||||
};
|
};
|
||||||
assert_ser_de(
|
assert_ser_de(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::common::Timeouts;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Locator {
|
pub struct Locator {
|
||||||
pub using: Selector,
|
pub using: Selector,
|
||||||
@ -28,6 +30,8 @@ pub enum Command {
|
|||||||
FindElements(Locator),
|
FindElements(Locator),
|
||||||
#[serde(rename = "WebDriver:GetTimeouts")]
|
#[serde(rename = "WebDriver:GetTimeouts")]
|
||||||
GetTimeouts,
|
GetTimeouts,
|
||||||
|
#[serde(rename = "WebDriver:SetTimeouts")]
|
||||||
|
SetTimeouts(Timeouts)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -2,6 +2,7 @@ use crate::command::{
|
|||||||
AddonInstallParameters, AddonUninstallParameters, GeckoContextParameters,
|
AddonInstallParameters, AddonUninstallParameters, GeckoContextParameters,
|
||||||
GeckoExtensionCommand, GeckoExtensionRoute, XblLocatorParameters, CHROME_ELEMENT_KEY,
|
GeckoExtensionCommand, GeckoExtensionRoute, XblLocatorParameters, CHROME_ELEMENT_KEY,
|
||||||
};
|
};
|
||||||
|
use marionette_rs::common::Timeouts as MarionetteTimeouts;
|
||||||
use marionette_rs::message::{Command, Message, MessageId, Request};
|
use marionette_rs::message::{Command, Message, MessageId, Request};
|
||||||
use marionette_rs::webdriver::{
|
use marionette_rs::webdriver::{
|
||||||
Command as MarionetteWebDriverCommand, Locator as MarionetteLocator,
|
Command as MarionetteWebDriverCommand, Locator as MarionetteLocator,
|
||||||
@ -801,6 +802,9 @@ fn try_convert_to_marionette_message(
|
|||||||
MarionetteWebDriverCommand::FindElements(x.to_marionette()?),
|
MarionetteWebDriverCommand::FindElements(x.to_marionette()?),
|
||||||
)),
|
)),
|
||||||
GetTimeouts => Some(Command::WebDriver(MarionetteWebDriverCommand::GetTimeouts)),
|
GetTimeouts => Some(Command::WebDriver(MarionetteWebDriverCommand::GetTimeouts)),
|
||||||
|
SetTimeouts(ref x) => Some(Command::WebDriver(MarionetteWebDriverCommand::SetTimeouts(
|
||||||
|
x.to_marionette()?,
|
||||||
|
))),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -995,7 +999,6 @@ impl MarionetteCommand {
|
|||||||
);
|
);
|
||||||
(Some("WebDriver:SendAlertText"), Some(Ok(data)))
|
(Some("WebDriver:SendAlertText"), Some(Ok(data)))
|
||||||
}
|
}
|
||||||
SetTimeouts(ref x) => (Some("WebDriver:SetTimeouts"), Some(x.to_marionette())),
|
|
||||||
SetWindowRect(ref x) => (Some("WebDriver:SetWindowRect"), Some(x.to_marionette())),
|
SetWindowRect(ref x) => (Some("WebDriver:SetWindowRect"), Some(x.to_marionette())),
|
||||||
SwitchToFrame(ref x) => (Some("WebDriver:SwitchToFrame"), Some(x.to_marionette())),
|
SwitchToFrame(ref x) => (Some("WebDriver:SwitchToFrame"), Some(x.to_marionette())),
|
||||||
SwitchToParentFrame => (Some("WebDriver:SwitchToParentFrame"), None),
|
SwitchToParentFrame => (Some("WebDriver:SwitchToParentFrame"), None),
|
||||||
@ -1558,14 +1561,16 @@ impl ToMarionette<Map<String, Value>> for SwitchToWindowParameters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToMarionette<Map<String, Value>> for TimeoutsParameters {
|
impl ToMarionette<MarionetteTimeouts> for TimeoutsParameters {
|
||||||
fn to_marionette(&self) -> WebDriverResult<Map<String, Value>> {
|
fn to_marionette(&self) -> WebDriverResult<MarionetteTimeouts> {
|
||||||
Ok(try_opt!(
|
Ok(MarionetteTimeouts {
|
||||||
serde_json::to_value(self)?.as_object(),
|
implicit: self.implicit.clone(),
|
||||||
ErrorStatus::UnknownError,
|
page_load: self.page_load.clone(),
|
||||||
"Expected an object"
|
script: match self.script {
|
||||||
)
|
Some(x) => x,
|
||||||
.clone())
|
None => None,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user