webdriver: command, httpapi: rename GetCookie to GetNamedCookie (#60)
authorAndreas Tolfsen <ato@mozilla.com>
Wed, 11 Jan 2017 13:31:44 +0000
changeset 428104 01f960ac5decfab0730d925551fbd089a10ff283
parent 428103 1be2cbe76412080e36bc8a39c34db67c63dfe421
child 428105 e20faabf188873793b401210314fdb19b0a2a9a4
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
webdriver: command, httpapi: rename GetCookie to GetNamedCookie (#60) The command for getting a single cookie by name is named ‘Get Named Cookie’ in the WebDriver specification. We should reflect this name in the Rust library. Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 7ec65451c99b638655c72e7b9718a374ff60de87 committer: jgraham <james@hoppipolla.co.uk>
testing/webdriver/src/command.rs
testing/webdriver/src/httpapi.rs
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -42,17 +42,17 @@ pub enum WebDriverCommand<T: WebDriverEx
     GetCSSValue(WebElement, String),
     GetElementText(WebElement),
     GetElementTagName(WebElement),
     GetElementRect(WebElement),
     IsEnabled(WebElement),
     ExecuteScript(JavascriptCommandParameters),
     ExecuteAsyncScript(JavascriptCommandParameters),
     GetCookies,
-    GetCookie(String),
+    GetNamedCookie(String),
     AddCookie(AddCookieParameters),
     DeleteCookies,
     DeleteCookie(String),
     GetTimeouts,
     SetTimeouts(TimeoutsParameters),
     ElementClick(WebElement),
     ElementTap(WebElement),
     ElementClear(WebElement),
@@ -286,21 +286,21 @@ impl <U: WebDriverExtensionRoute> WebDri
             },
             Route::ExecuteAsyncScript => {
                 let parameters: JavascriptCommandParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::ExecuteAsyncScript(parameters)
             },
             Route::GetCookies => {
                 WebDriverCommand::GetCookies
             },
-            Route::GetCookie => {
+            Route::GetNamedCookie => {
                 let name = try_opt!(params.name("name"),
                                     ErrorStatus::InvalidArgument,
-                                    "Missing name parameter").as_str().into();
-                WebDriverCommand::GetCookie(name)
+                                    "Missing 'name' parameter").as_str().into();
+                WebDriverCommand::GetNamedCookie(name)
             },
             Route::AddCookie => {
                 let parameters: AddCookieParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::AddCookie(parameters)
             },
             Route::DeleteCookies => {
                 WebDriverCommand::DeleteCookies
             },
@@ -361,17 +361,17 @@ impl <U:WebDriverExtensionRoute> ToJson 
             WebDriverCommand::DeleteCookies |
             WebDriverCommand::DeleteSession |
             WebDriverCommand::DismissAlert |
             WebDriverCommand::ElementClear(_) |
             WebDriverCommand::ElementClick(_) |
             WebDriverCommand::ElementTap(_) |
             WebDriverCommand::GetActiveElement |
             WebDriverCommand::GetAlertText |
-            WebDriverCommand::GetCookie(_) |
+            WebDriverCommand::GetNamedCookie(_) |
             WebDriverCommand::GetCookies |
             WebDriverCommand::GetCSSValue(_, _) |
             WebDriverCommand::GetCurrentUrl |
             WebDriverCommand::GetElementAttribute(_, _) |
             WebDriverCommand::GetElementProperty(_, _) |
             WebDriverCommand::GetElementRect(_) |
             WebDriverCommand::GetElementTagName(_) |
             WebDriverCommand::GetElementText(_) |
@@ -814,41 +814,39 @@ impl ToJson for JavascriptCommandParamet
         //TODO: Wrap script so that it becomes marionette-compatible
         data.insert("script".to_string(), self.script.to_json());
         data.insert("args".to_string(), self.args.to_json());
         Json::Object(data)
     }
 }
 
 #[derive(PartialEq)]
-pub struct GetCookieParameters {
-    pub name: Nullable<String>
+pub struct GetNamedCookieParameters {
+    pub name: Nullable<String>,
 }
 
-impl Parameters for GetCookieParameters {
-    fn from_json(body: &Json) -> WebDriverResult<GetCookieParameters> {
-        let data = try_opt!(body.as_object(), ErrorStatus::InvalidArgument,
+impl Parameters for GetNamedCookieParameters {
+    fn from_json(body: &Json) -> WebDriverResult<GetNamedCookieParameters> {
+        let data = try_opt!(body.as_object(),
+                            ErrorStatus::InvalidArgument,
                             "Message body was not an object");
         let name_json = try_opt!(data.get("name"),
                                  ErrorStatus::InvalidArgument,
                                  "Missing 'name' parameter");
-        let name = try!(Nullable::from_json(
-            name_json,
-            |x| {
-                Ok(try_opt!(x.as_string(),
-                            ErrorStatus::InvalidArgument,
-                            "Failed to convert name to String").to_string())
-            }));
-        return Ok(GetCookieParameters {
-            name: name
-        })
+        let name = try!(Nullable::from_json(name_json, |x| {
+            Ok(try_opt!(x.as_string(),
+                        ErrorStatus::InvalidArgument,
+                        "Failed to convert name to string")
+                .to_string())
+        }));
+        return Ok(GetNamedCookieParameters { name: name });
     }
 }
 
-impl ToJson for GetCookieParameters {
+impl ToJson for GetNamedCookieParameters {
     fn to_json(&self) -> Json {
         let mut data = BTreeMap::new();
         data.insert("name".to_string(), self.name.to_json());
         Json::Object(data)
     }
 }
 
 #[derive(PartialEq)]
--- a/testing/webdriver/src/httpapi.rs
+++ b/testing/webdriver/src/httpapi.rs
@@ -41,17 +41,17 @@ fn standard_routes<U:WebDriverExtensionR
                 (Get, "/session/{sessionId}/element/{elementId}/css/{propertyName}", Route::GetCSSValue),
                 (Get, "/session/{sessionId}/element/{elementId}/text", Route::GetElementText),
                 (Get, "/session/{sessionId}/element/{elementId}/name", Route::GetElementTagName),
                 (Get, "/session/{sessionId}/element/{elementId}/rect", Route::GetElementRect),
                 (Get, "/session/{sessionId}/element/{elementId}/enabled", Route::IsEnabled),
                 (Post, "/session/{sessionId}/execute/sync", Route::ExecuteScript),
                 (Post, "/session/{sessionId}/execute/async", Route::ExecuteAsyncScript),
                 (Get, "/session/{sessionId}/cookie", Route::GetCookies),
-                (Get, "/session/{sessionId}/cookie/{name}", Route::GetCookie),
+                (Get, "/session/{sessionId}/cookie/{name}", Route::GetNamedCookie),
                 (Post, "/session/{sessionId}/cookie", Route::AddCookie),
                 (Delete, "/session/{sessionId}/cookie", Route::DeleteCookies),
                 (Delete, "/session/{sessionId}/cookie/{name}", Route::DeleteCookie),
                 (Get, "/session/{sessionId}/timeouts", Route::GetTimeouts),
                 (Post, "/session/{sessionId}/timeouts", Route::SetTimeouts),
                 //(Post, "/session/{sessionId}/actions", Route::Actions),
                 (Post, "/session/{sessionId}/element/{elementId}/click", Route::ElementClick),
                 (Post, "/session/{sessionId}/element/{elementId}/tap", Route::ElementTap),
@@ -113,17 +113,17 @@ pub enum Route<U:WebDriverExtensionRoute
     GetCSSValue,
     GetElementText,
     GetElementTagName,
     GetElementRect,
     IsEnabled,
     ExecuteScript,
     ExecuteAsyncScript,
     GetCookies,
-    GetCookie,
+    GetNamedCookie,
     AddCookie,
     DeleteCookies,
     DeleteCookie,
     GetTimeouts,
     SetTimeouts,
     ElementClick,
     ElementTap,
     ElementClear,
@@ -132,17 +132,17 @@ pub enum Route<U:WebDriverExtensionRoute
     ReleaseActions,
     DismissAlert,
     AcceptAlert,
     GetAlertText,
     SendAlertText,
     TakeScreenshot,
     TakeElementScreenshot,
     Status,
-    Extension(U)
+    Extension(U),
 }
 
 pub trait WebDriverExtensionRoute : Clone + Send + PartialEq {
     type Command: WebDriverExtensionCommand + 'static;
 
     fn command(&self, &Captures, &Json) -> WebDriverResult<WebDriverCommand<Self::Command>>;
 }