зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1569100 - Add GetCookies command and Cookies response types. r=ato
Differential Revision: https://phabricator.services.mozilla.com/D39838 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5c9e948681
Коммит
c356668e9c
|
@ -1,7 +1,7 @@
|
|||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::common::{Timeouts, WebElement};
|
||||
use crate::common::{Cookie, Timeouts, WebElement};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
|
@ -13,6 +13,7 @@ pub enum MarionetteResult {
|
|||
#[serde(deserialize_with = "from_value", serialize_with = "to_value")]
|
||||
WebElement(WebElement),
|
||||
WebElements(Vec<WebElement>),
|
||||
Cookies(Vec<Cookie>),
|
||||
Timeouts(Timeouts),
|
||||
}
|
||||
|
||||
|
@ -62,6 +63,24 @@ mod tests {
|
|||
use crate::test::{assert_ser_de, ELEMENT_KEY};
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn test_cookies_response() {
|
||||
let mut data = Vec::new();
|
||||
data.push(Cookie {
|
||||
name: "foo".into(),
|
||||
value: "bar".into(),
|
||||
path: Some("/common".into()),
|
||||
domain: Some("web-platform.test".into()),
|
||||
secure: false,
|
||||
http_only: false,
|
||||
expiry: None,
|
||||
});
|
||||
assert_ser_de(
|
||||
&MarionetteResult::Cookies(data),
|
||||
json!([{"name":"foo","value":"bar","path":"/common","domain":"web-platform.test","secure":false,"httpOnly":false}]),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_web_element_response() {
|
||||
let data = WebElement {
|
||||
|
|
|
@ -34,6 +34,8 @@ pub enum Command {
|
|||
FindElement(Locator),
|
||||
#[serde(rename = "WebDriver:FindElements")]
|
||||
FindElements(Locator),
|
||||
#[serde(rename = "WebDriver:GetCookies")]
|
||||
GetCookies,
|
||||
#[serde(rename = "WebDriver:GetTimeouts")]
|
||||
GetTimeouts,
|
||||
#[serde(rename = "WebDriver:SetTimeouts")]
|
||||
|
|
|
@ -806,6 +806,7 @@ fn try_convert_to_marionette_message(
|
|||
FindElements(ref x) => Some(Command::WebDriver(
|
||||
MarionetteWebDriverCommand::FindElements(x.to_marionette()?),
|
||||
)),
|
||||
GetCookies => Some(Command::WebDriver(MarionetteWebDriverCommand::GetCookies)),
|
||||
GetTimeouts => Some(Command::WebDriver(MarionetteWebDriverCommand::GetTimeouts)),
|
||||
SetTimeouts(ref x) => Some(Command::WebDriver(MarionetteWebDriverCommand::SetTimeouts(
|
||||
x.to_marionette()?,
|
||||
|
@ -929,7 +930,7 @@ impl MarionetteCommand {
|
|||
Get(ref x) => (Some("WebDriver:Navigate"), Some(x.to_marionette())),
|
||||
GetAlertText => (Some("WebDriver:GetAlertText"), None),
|
||||
GetActiveElement => (Some("WebDriver:GetActiveElement"), None),
|
||||
GetCookies | GetNamedCookie(_) => (Some("WebDriver:GetCookies"), None),
|
||||
GetNamedCookie(_) => (Some("WebDriver:GetCookies"), None),
|
||||
GetCurrentUrl => (Some("WebDriver:GetCurrentURL"), None),
|
||||
GetCSSValue(ref e, ref x) => {
|
||||
let mut data = Map::new();
|
||||
|
|
Загрузка…
Ссылка в новой задаче