Bug 1682497 - [geckodriver] Added Page Range for Integers r=webdriver-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D182624
This commit is contained in:
Mitesh Gulecha 2023-08-21 09:01:34 +00:00
Родитель 9a309c9c2a
Коммит 36be3bbb25
3 изменённых файлов: 37 добавлений и 8 удалений

Просмотреть файл

@ -56,6 +56,13 @@ pub struct Keys {
pub value: Vec<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PrintPageRange {
Integer(u64),
Range(String),
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct PrintParameters {
@ -64,7 +71,7 @@ pub struct PrintParameters {
pub background: bool,
pub page: PrintPage,
pub margin: PrintMargins,
pub page_ranges: Vec<String>,
pub page_ranges: Vec<PrintPageRange>,
pub shrink_to_fit: bool,
}

Просмотреть файл

@ -22,9 +22,10 @@ use marionette_rs::webdriver::{
Command as MarionetteWebDriverCommand, CredentialParameters as MarionetteCredentialParameters,
Keys as MarionetteKeys, Locator as MarionetteLocator, NewWindow as MarionetteNewWindow,
PrintMargins as MarionettePrintMargins, PrintOrientation as MarionettePrintOrientation,
PrintPage as MarionettePrintPage, PrintParameters as MarionettePrintParameters,
ScreenshotOptions, Script as MarionetteScript, Selector as MarionetteSelector,
Url as MarionetteUrl, UserVerificationParameters as MarionetteUserVerificationParameters,
PrintPage as MarionettePrintPage, PrintPageRange as MarionettePrintPageRange,
PrintParameters as MarionettePrintParameters, ScreenshotOptions, Script as MarionetteScript,
Selector as MarionetteSelector, Url as MarionetteUrl,
UserVerificationParameters as MarionetteUserVerificationParameters,
WebAuthnProtocol as MarionetteWebAuthnProtocol, WindowRect as MarionetteWindowRect,
};
use mozdevice::AndroidStorageInput;
@ -61,8 +62,9 @@ use webdriver::command::{
ActionsParameters, AddCookieParameters, AuthenticatorParameters, AuthenticatorTransport,
GetNamedCookieParameters, GetParameters, JavascriptCommandParameters, LocatorParameters,
NewSessionParameters, NewWindowParameters, PrintMargins, PrintOrientation, PrintPage,
PrintParameters, SendKeysParameters, SwitchToFrameParameters, SwitchToWindowParameters,
TimeoutsParameters, UserVerificationParameters, WebAuthnProtocol, WindowRectParameters,
PrintPageRange, PrintParameters, SendKeysParameters, SwitchToFrameParameters,
SwitchToWindowParameters, TimeoutsParameters, UserVerificationParameters, WebAuthnProtocol,
WindowRectParameters,
};
use webdriver::command::{WebDriverCommand, WebDriverMessage};
use webdriver::common::{
@ -1467,7 +1469,11 @@ impl ToMarionette<MarionettePrintParameters> for PrintParameters {
background: self.background,
page: self.page.to_marionette()?,
margin: self.margin.to_marionette()?,
page_ranges: self.page_ranges.clone(),
page_ranges: self
.page_ranges
.iter()
.map(|x| x.to_marionette())
.collect::<WebDriverResult<Vec<_>>>()?,
shrink_to_fit: self.shrink_to_fit,
})
}
@ -1491,6 +1497,15 @@ impl ToMarionette<MarionettePrintPage> for PrintPage {
}
}
impl ToMarionette<MarionettePrintPageRange> for PrintPageRange {
fn to_marionette(&self) -> WebDriverResult<MarionettePrintPageRange> {
Ok(match self {
PrintPageRange::Integer(num) => MarionettePrintPageRange::Integer(*num),
PrintPageRange::Range(range) => MarionettePrintPageRange::Range(range.clone()),
})
}
}
impl ToMarionette<MarionettePrintMargins> for PrintMargins {
fn to_marionette(&self) -> WebDriverResult<MarionettePrintMargins> {
Ok(MarionettePrintMargins {

Просмотреть файл

@ -572,6 +572,13 @@ pub struct NewWindowParameters {
pub type_hint: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PrintPageRange {
Integer(u64),
Range(String),
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")]
pub struct PrintParameters {
@ -581,7 +588,7 @@ pub struct PrintParameters {
pub background: bool,
pub page: PrintPage,
pub margin: PrintMargins,
pub page_ranges: Vec<String>,
pub page_ranges: Vec<PrintPageRange>,
pub shrink_to_fit: bool,
}