webdriver: Merge pull request #61 from upsuper/upgrade-regex
authorXidorn Quan <me@upsuper.org>
Wed, 11 Jan 2017 13:10:00 +0000
changeset 428103 1be2cbe76412080e36bc8a39c34db67c63dfe421
parent 428102 81dbb8d118f3cf9e3e88220036773a5d82036648
child 428104 01f960ac5decfab0730d925551fbd089a10ff283
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: Merge pull request #61 from upsuper/upgrade-regex Upgrade regex to 0.2 Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 14094d6a75a46577edb21eb59896460fcf4e9722
testing/webdriver/Cargo.toml
testing/webdriver/src/command.rs
--- a/testing/webdriver/Cargo.toml
+++ b/testing/webdriver/Cargo.toml
@@ -1,16 +1,16 @@
 [package]
 
 name = "webdriver"
-version = "0.18.0"
+version = "0.18.1"
 authors = ["Mozilla Tools and Automation <auto-tools@mozilla.com>"]
 description = "Library implementing the wire protocol for the W3C WebDriver specification."
 repository = "https://github.com/jgraham/webdriver-rust"
 license = "MPL-2.0"
 
 [dependencies]
 log = "0.3"
-regex = "0.1"
+regex = "0.2"
 rustc-serialize = "0.3"
 hyper = {version = "0.9", default-features = false}
 cookie = {version = "0.2", default-features = false}
 time = "0.1"
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -161,127 +161,127 @@ impl <U: WebDriverExtensionRoute> WebDri
             Route::FindElements => {
                 let parameters: LocatorParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::FindElements(parameters)
             },
             Route::FindElementElement => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 let parameters: LocatorParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::FindElementElement(element, parameters)
             },
             Route::FindElementElements => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 let parameters: LocatorParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::FindElementElements(element, parameters)
             },
             Route::GetActiveElement => WebDriverCommand::GetActiveElement,
             Route::IsDisplayed => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::IsDisplayed(element)
             },
             Route::IsSelected => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::IsSelected(element)
             },
             Route::GetElementAttribute => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 let attr = try_opt!(params.name("name"),
                                     ErrorStatus::InvalidArgument,
-                                    "Missing name parameter").to_string();
-                WebDriverCommand::GetElementAttribute(element, attr)
+                                    "Missing name parameter").as_str();
+                WebDriverCommand::GetElementAttribute(element, attr.into())
             },
             Route::GetElementProperty => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 let property = try_opt!(params.name("name"),
                                         ErrorStatus::InvalidArgument,
-                                        "Missing name parameter").to_string();
-                WebDriverCommand::GetElementProperty(element, property)
+                                        "Missing name parameter").as_str();
+                WebDriverCommand::GetElementProperty(element, property.into())
             },
             Route::GetCSSValue => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 let property = try_opt!(params.name("propertyName"),
                                         ErrorStatus::InvalidArgument,
-                                        "Missing propertyName parameter").to_string();
-                WebDriverCommand::GetCSSValue(element, property)
+                                        "Missing propertyName parameter").as_str();
+                WebDriverCommand::GetCSSValue(element, property.into())
             },
             Route::GetElementText => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::GetElementText(element)
             },
             Route::GetElementTagName => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::GetElementTagName(element)
             },
             Route::GetElementRect => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::GetElementRect(element)
             },
             Route::IsEnabled => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::IsEnabled(element)
             },
             Route::ElementClick => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::ElementClick(element)
             },
             Route::ElementTap => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::ElementTap(element)
             },
             Route::ElementClear => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::ElementClear(element)
             },
             Route::ElementSendKeys => {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 let parameters: SendKeysParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::ElementSendKeys(element, parameters)
             },
             Route::ExecuteScript => {
                 let parameters: JavascriptCommandParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::ExecuteScript(parameters)
             },
             Route::ExecuteAsyncScript => {
@@ -289,30 +289,30 @@ impl <U: WebDriverExtensionRoute> WebDri
                 WebDriverCommand::ExecuteAsyncScript(parameters)
             },
             Route::GetCookies => {
                 WebDriverCommand::GetCookies
             },
             Route::GetCookie => {
                 let name = try_opt!(params.name("name"),
                                     ErrorStatus::InvalidArgument,
-                                    "Missing name parameter").to_string();
+                                    "Missing name parameter").as_str().into();
                 WebDriverCommand::GetCookie(name)
             },
             Route::AddCookie => {
                 let parameters: AddCookieParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::AddCookie(parameters)
             },
             Route::DeleteCookies => {
                 WebDriverCommand::DeleteCookies
             },
             Route::DeleteCookie => {
                 let name = try_opt!(params.name("name"),
                                     ErrorStatus::InvalidArgument,
-                                    "Missing name parameter").to_string();
+                                    "Missing name parameter").as_str().into();
                 WebDriverCommand::DeleteCookie(name)
             },
             Route::PerformActions => {
                 let parameters: ActionsParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::PerformActions(parameters)
             },
             Route::ReleaseActions => {
                 WebDriverCommand::ReleaseActions
@@ -330,29 +330,29 @@ impl <U: WebDriverExtensionRoute> WebDri
                 let parameters: SendKeysParameters = try!(Parameters::from_json(&body_data));
                 WebDriverCommand::SendAlertText(parameters)
             },
             Route::TakeScreenshot => WebDriverCommand::TakeScreenshot,
             Route::TakeElementScreenshot =>  {
                 let element_id = try_opt!(params.name("elementId"),
                                           ErrorStatus::InvalidArgument,
                                           "Missing elementId parameter");
-                let element = WebElement::new(element_id.to_string());
+                let element = WebElement::new(element_id.as_str().into());
                 WebDriverCommand::TakeElementScreenshot(element)
             },
             Route::Status => WebDriverCommand::Status,
             Route::Extension(ref extension) => {
                 try!(extension.command(params, &body_data))
             }
         };
         Ok(WebDriverMessage::new(session_id, command))
     }
 
     fn get_session_id(params: &Captures) -> Option<String> {
-        params.name("sessionId").map(|x| x.to_string())
+        params.name("sessionId").map(|x| x.as_str().into())
     }
 }
 
 impl <U:WebDriverExtensionRoute> ToJson for WebDriverMessage<U> {
     fn to_json(&self) -> Json {
         let parameters = match self.command {
             WebDriverCommand::AcceptAlert |
             WebDriverCommand::CloseWindow |