Backed out changeset 1f94fa48c7dc (bug 1396819) for build bustage
authorGurzau Raul <rgurzau@mozilla.com>
Mon, 19 Feb 2018 14:21:12 +0200
changeset 404400 ca5ab7d0c716eed612ef41fb433806de231dce4e
parent 404399 e2d9024ddc20e91c3394cde0d1c9650ae27bce22
child 404401 387d87eb05f8a5917657e2a42f21d56dc735e6d3
push id100000
push userncsoregi@mozilla.com
push dateMon, 19 Feb 2018 16:46:49 +0000
treeherdermozilla-inbound@176fb0d46b64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1396819
milestone60.0a1
backs out1f94fa48c7dc1452be45418ef956caf6de054c29
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
Backed out changeset 1f94fa48c7dc (bug 1396819) for build bustage
testing/webdriver/src/capabilities.rs
testing/webdriver/src/command.rs
--- a/testing/webdriver/src/capabilities.rs
+++ b/testing/webdriver/src/capabilities.rs
@@ -82,40 +82,40 @@ impl SpecNewSessionParameters {
         for key in null_entries {
             capabilities.remove(&key);
         }
 
         for (key, value) in capabilities.iter() {
             match &**key {
                 "acceptInsecureCerts" => if !value.is_boolean() {
                         return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
-                                                       format!("acceptInsecureCerts is not boolean: {}", value)))
+                                                       "acceptInsecureCerts is not a boolean"))
                     },
                 x @ "browserName" |
                 x @ "browserVersion" |
                 x @ "platformName" => if !value.is_string() {
                         return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
-                                                       format!("{} is not a string: {}", x, value)))
+                                                       format!("{} is not a string", x)))
                     },
                 "pageLoadStrategy" => {
                     try!(SpecNewSessionParameters::validate_page_load_strategy(value))
                 }
                 "proxy" => {
                     try!(SpecNewSessionParameters::validate_proxy(value))
                 },
                 "timeouts" => {
                     try!(SpecNewSessionParameters::validate_timeouts(value))
                 },
                 "unhandledPromptBehavior" => {
                     try!(SpecNewSessionParameters::validate_unhandled_prompt_behaviour(value))
                 }
                 x => {
                     if !x.contains(":") {
                         return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
-                                                       format!("{} is not the name of a known capability or extension capability", x)))
+                                                       format!("{} is not the name of a known capability or a valid extension capability", x)))
                     } else {
                         try!(browser_capabilities.validate_custom(x, value));
                     }
                 }
             }
         }
         Ok(capabilities)
     }
@@ -125,242 +125,203 @@ impl SpecNewSessionParameters {
             &Json::String(ref x) => {
                 match &**x {
                     "normal" |
                     "eager" |
                     "none" => {},
                     x => {
                         return Err(WebDriverError::new(
                             ErrorStatus::InvalidArgument,
-                            format!("Invalid page load strategy: {}", x)))
+                            format!("\"{}\" is not a valid page load strategy", x)))
                     }
                 }
             }
             _ => return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
                                                 "pageLoadStrategy is not a string"))
         }
         Ok(())
     }
 
     fn validate_proxy(proxy_value: &Json) -> WebDriverResult<()> {
         let obj = try_opt!(proxy_value.as_object(),
                            ErrorStatus::InvalidArgument,
                            "proxy is not an object");
-
         for (key, value) in obj.iter() {
             match &**key {
                 "proxyType" => match value.as_string() {
                     Some("pac") |
                     Some("direct") |
                     Some("autodetect") |
                     Some("system") |
                     Some("manual") => {},
                     Some(x) => return Err(WebDriverError::new(
                         ErrorStatus::InvalidArgument,
-                        format!("Invalid proxyType value: {}", x))),
+                        format!("{} is not a valid proxyType value", x))),
                     None => return Err(WebDriverError::new(
                         ErrorStatus::InvalidArgument,
-                        format!("proxyType is not a string: {}", value))),
+                        "proxyType value is not a string")),
                 },
-
                 "proxyAutoconfigUrl" => match value.as_string() {
                     Some(x) => {
-                        Url::parse(x).or(Err(WebDriverError::new(
+                        try!(Url::parse(x).or(Err(WebDriverError::new(
                             ErrorStatus::InvalidArgument,
-                            format!("proxyAutoconfigUrl is not a valid URL: {}", x))))?;
+                            "proxyAutoconfigUrl is not a valid url"))));
                     },
                     None => return Err(WebDriverError::new(
                         ErrorStatus::InvalidArgument,
                         "proxyAutoconfigUrl is not a string"
                     ))
                 },
-
-                "ftpProxy" => SpecNewSessionParameters::validate_host(value, "ftpProxy")?,
-                "httpProxy" => SpecNewSessionParameters::validate_host(value, "httpProxy")?,
-                "noProxy" => SpecNewSessionParameters::validate_no_proxy(value)?,
-                "sslProxy" => SpecNewSessionParameters::validate_host(value, "sslProxy")?,
-                "socksProxy" => SpecNewSessionParameters::validate_host(value, "socksProxy")?,
+                "ftpProxy" => try!(SpecNewSessionParameters::validate_host(value)),
+                "httpProxy" => try!(SpecNewSessionParameters::validate_host(value)),
+                "noProxy" => try!(SpecNewSessionParameters::validate_no_proxy(value)),
+                "sslProxy" => try!(SpecNewSessionParameters::validate_host(value)),
+                "socksProxy" => try!(SpecNewSessionParameters::validate_host(value)),
                 "socksVersion" => if !value.is_number() {
-                    return Err(WebDriverError::new(
-                        ErrorStatus::InvalidArgument,
-                        format!("socksVersion is not a number: {}", value)
-                    ))
+                    return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
+                                                   "socksVersion is not a number"))
                 },
-
                 x => return Err(WebDriverError::new(
                     ErrorStatus::InvalidArgument,
-                    format!("Invalid proxy configuration entry: {}", x)))
+                    format!("{} is not a valid proxy configuration capability", x)))
             }
         }
-
         Ok(())
     }
 
     fn validate_no_proxy(value: &Json) -> WebDriverResult<()> {
         match value.as_array() {
             Some(hosts) => {
                 for host in hosts {
                     match host.as_string() {
                         Some(_) => {},
                         None => return Err(WebDriverError::new(
                             ErrorStatus::InvalidArgument,
-                            format!("noProxy item is not a string: {}", host)
+                            format!("{} is not a string", host)
                         ))
                     }
                 }
             },
             None => return Err(WebDriverError::new(
                 ErrorStatus::InvalidArgument,
-                format!("noProxy is not an array: {}", value)
+                format!("{} is not an array", value)
             ))
         }
 
         Ok(())
     }
 
     /// Validate whether a named capability is JSON value is a string containing a host
     /// and possible port
-    fn validate_host(value: &Json, entry: &str) -> WebDriverResult<()> {
+    fn validate_host(value: &Json) -> WebDriverResult<()> {
         match value.as_string() {
             Some(host) => {
                 if host.contains("://") {
                     return Err(WebDriverError::new(
                         ErrorStatus::InvalidArgument,
-                        format!("{} must not contain a scheme: {}", entry, host)));
+                        format!("{} contains a scheme", host)));
                 }
 
                 // Temporarily add a scheme so the host can be parsed as URL
                 let s = String::from(format!("http://{}", host));
-                let url = Url::parse(s.as_str()).or(Err(WebDriverError::new(
+                let url = try!(Url::parse(s.as_str()).or(Err(WebDriverError::new(
                     ErrorStatus::InvalidArgument,
-                    format!("{} is not a valid URL: {}", entry, host))))?;
+                    format!("{} is not a valid host", host)))));
 
                 if url.username() != "" ||
                     url.password() != None ||
                     url.path() != "/" ||
                     url.query() != None ||
                     url.fragment() != None {
                         return Err(WebDriverError::new(
                             ErrorStatus::InvalidArgument,
-                            format!("{} is not of the form host[:port]: {}", entry, host)));
+                            format!("{} is not of the form host[:port]", host)));
                     }
             },
-
             None => return Err(WebDriverError::new(
                 ErrorStatus::InvalidArgument,
-                format!("{} is not a string: {}", entry, value)
+                format!("{} is not a string", value)
             ))
         }
-
         Ok(())
     }
 
     fn validate_timeouts(value: &Json) -> WebDriverResult<()> {
-        let obj = try_opt!(
-            value.as_object(),
-            ErrorStatus::InvalidArgument,
-            "timeouts capability is not an object"
-        );
-
+        let obj = try_opt!(value.as_object(),
+                           ErrorStatus::InvalidArgument,
+                           "timeouts capability is not an object");
         for (key, value) in obj.iter() {
             match &**key {
-                x @ "script" | x @ "pageLoad" | x @ "implicit" => {
-                    let timeout = try_opt!(
-                        value.as_i64(),
-                        ErrorStatus::InvalidArgument,
-                        format!("{} timeouts value is not an integer: {}", x, value)
-                    );
+                x @ "script" |
+                x @ "pageLoad" |
+                x @ "implicit" => {
+                    let timeout = try_opt!(value.as_i64(),
+                                           ErrorStatus::InvalidArgument,
+                                           format!("{} timeouts value is not an integer", x));
                     if timeout < 0 {
-                        return Err(WebDriverError::new(
-                            ErrorStatus::InvalidArgument,
-                            format!("{} timeouts value is negative: {}", x, timeout),
-                        ));
+                        return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
+                                                       format!("{} timeouts value is negative", x)))
                     }
-                }
-
-                x => {
-                    return Err(WebDriverError::new(
-                        ErrorStatus::InvalidArgument,
-                        format!("Invalid timeouts capability entry: {}", x),
-                    ))
-                }
+                },
+                x => return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
+                                                    format!("{} is not a valid timeouts capability", x)))
             }
         }
-
         Ok(())
     }
 
     fn validate_unhandled_prompt_behaviour(value: &Json) -> WebDriverResult<()> {
-        let behaviour = try_opt!(
-            value.as_string(),
-            ErrorStatus::InvalidArgument,
-            format!("unhandledPromptBehavior is not a string: {}", value)
-        );
-
+        let behaviour = try_opt!(value.as_string(),
+                                 ErrorStatus::InvalidArgument,
+                                 "unhandledPromptBehavior capability is not a string");
         match behaviour {
-            "dismiss" | "accept" => {}
-            x => {
-                return Err(WebDriverError::new(
-                    ErrorStatus::InvalidArgument,
-                    format!("Invalid unhandledPromptBehavior value: {}", x),
-                ))
-            }
-        }
-
+            "dismiss" |
+            "accept" => {},
+            x => return Err(WebDriverError::new(ErrorStatus::InvalidArgument,
+                                                format!("{} is not a valid unhandledPromptBehavior value", x)))        }
         Ok(())
     }
 }
 
 impl Parameters for SpecNewSessionParameters {
     fn from_json(body: &Json) -> WebDriverResult<SpecNewSessionParameters> {
-        let data = try_opt!(
-            body.as_object(),
-            ErrorStatus::UnknownError,
-            format!("Malformed capabilities, message body is not an object: {}", body)
-        );
+        let data = try_opt!(body.as_object(),
+                            ErrorStatus::UnknownError,
+                            "Message body is not an object");
 
         let capabilities = try_opt!(
-            try_opt!(
-                data.get("capabilities"),
-                ErrorStatus::InvalidArgument,
-                "Malformed capabilities, missing \"capabilities\" field"
-            ).as_object(),
+            try_opt!(data.get("capabilities"),
+                     ErrorStatus::InvalidArgument,
+                     "Missing 'capabilities' parameter").as_object(),
             ErrorStatus::InvalidArgument,
-            "Malformed capabilities, \"capabilities\" field is not an object}"
-        );
+                     "'capabilities' parameter is not an object");
 
         let default_always_match = Json::Object(Capabilities::new());
-        let always_match = try_opt!(
-            capabilities
-                .get("alwaysMatch")
-                .unwrap_or(&default_always_match)
-                .as_object(),
-            ErrorStatus::InvalidArgument,
-            "Malformed capabilities, alwaysMatch field is not an object"
-        );
+        let always_match = try_opt!(capabilities.get("alwaysMatch")
+                                   .unwrap_or(&default_always_match)
+                                   .as_object(),
+                                   ErrorStatus::InvalidArgument,
+                                   "'alwaysMatch' parameter is not an object");
         let default_first_matches = Json::Array(vec![]);
-        let first_matches = try_opt!(
-            capabilities
-                .get("firstMatch")
-                .unwrap_or(&default_first_matches)
-                .as_array(),
-            ErrorStatus::InvalidArgument,
-            "Malformed capabilities, firstMatch field is not an array"
-        ).iter()
-            .map(|x| {
-                x.as_object().map(|x| x.clone()).ok_or(WebDriverError::new(
-                    ErrorStatus::InvalidArgument,
-                    "Malformed capabilities, firstMatch entry is not an object",
-                ))
-            })
-            .collect::<WebDriverResult<Vec<Capabilities>>>()?;
+        let first_matches = try!(
+            try_opt!(capabilities.get("firstMatch")
+                     .unwrap_or(&default_first_matches)
+                     .as_array(),
+                     ErrorStatus::InvalidArgument,
+                     "'firstMatch' parameter is not an array")
+                .iter()
+                .map(|x| x.as_object()
+                     .map(|x| x.clone())
+                     .ok_or(WebDriverError::new(ErrorStatus::InvalidArgument,
+                                                "'firstMatch' entry is not an object")))
+                .collect::<WebDriverResult<Vec<Capabilities>>>());
 
         return Ok(SpecNewSessionParameters {
             alwaysMatch: always_match.clone(),
-            firstMatch: first_matches,
+            firstMatch: first_matches
         });
     }
 }
 
 impl ToJson for SpecNewSessionParameters {
     fn to_json(&self) -> Json {
         let mut body = BTreeMap::new();
         let mut capabilities = BTreeMap::new();
@@ -381,20 +342,23 @@ impl CapabilitiesMatching for SpecNewSes
             &self.firstMatch
         } else {
             &default
         };
 
         let merged_capabilities = capabilities_list
             .iter()
             .map(|first_match_entry| {
-                if first_match_entry.keys().any(|k| self.alwaysMatch.contains_key(k)) {
+                if first_match_entry.keys().any(
+                    |k| self.alwaysMatch.contains_key(k),
+                )
+                {
                     return Err(WebDriverError::new(
                         ErrorStatus::InvalidArgument,
-                        "firstMatch key shadowed a value in alwaysMatch",
+                        "'firstMatch' key shadowed a value in 'alwaysMatch'",
                     ));
                 }
                 let mut merged = self.alwaysMatch.clone();
                 merged.append(&mut first_match_entry.clone());
                 Ok(merged)
             })
             .map(|merged| {
                 merged.and_then(|x| self.validate(x, browser_capabilities))
@@ -513,59 +477,58 @@ impl CapabilitiesMatching for LegacyNewS
         );
         browser_capabilities.init(&capabilities);
         Ok(Some(capabilities))
     }
 }
 
 impl Parameters for LegacyNewSessionParameters {
     fn from_json(body: &Json) -> WebDriverResult<LegacyNewSessionParameters> {
-        let data = try_opt!(
-            body.as_object(),
-            ErrorStatus::UnknownError,
-            format!("Malformed legacy capabilities, message body is not an object: {}")
-        );
+        let data = try_opt!(body.as_object(),
+                            ErrorStatus::UnknownError,
+                            "Message body is not an object");
+
+        let desired_capabilities =
+            if let Some(capabilities) = data.get("desiredCapabilities") {
+                try_opt!(capabilities.as_object(),
+                         ErrorStatus::InvalidArgument,
+                         "'desiredCapabilities' parameter is not an object").clone()
+            } else {
+                BTreeMap::new()
+            };
 
-        let desired = if let Some(capabilities) = data.get("desiredCapabilities") {
-            try_opt!(
-                capabilities.as_object(),
-                ErrorStatus::InvalidArgument,
-                "Malformed legacy capabilities, desiredCapabilities field is not an object"
-            ).clone()
-        } else {
-            BTreeMap::new()
-        };
+        let required_capabilities =
+            if let Some(capabilities) = data.get("requiredCapabilities") {
+                try_opt!(capabilities.as_object(),
+                         ErrorStatus::InvalidArgument,
+                         "'requiredCapabilities' parameter is not an object").clone()
+            } else {
+                BTreeMap::new()
+            };
 
-        let required = if let Some(capabilities) = data.get("requiredCapabilities") {
-            try_opt!(
-                capabilities.as_object(),
-                ErrorStatus::InvalidArgument,
-                "Malformed legacy capabilities, requiredCapabilities field is not an object"
-            ).clone()
-        } else {
-            BTreeMap::new()
-        };
-
-        Ok(LegacyNewSessionParameters { desired, required })
+        Ok(LegacyNewSessionParameters {
+            desired: desired_capabilities,
+            required: required_capabilities
+        })
     }
 }
 
 impl ToJson for LegacyNewSessionParameters {
     fn to_json(&self) -> Json {
         let mut data = BTreeMap::new();
         data.insert("desiredCapabilities".to_owned(), self.desired.to_json());
         data.insert("requiredCapabilities".to_owned(), self.required.to_json());
         Json::Object(data)
     }
 }
 
 #[cfg(test)]
 mod tests {
     use rustc_serialize::json::Json;
-    use super::{SpecNewSessionParameters, WebDriverResult};
+    use super::{WebDriverResult, SpecNewSessionParameters};
 
     fn validate_proxy(value: &str) -> WebDriverResult<()> {
         let data = Json::from_str(value).unwrap();
         SpecNewSessionParameters::validate_proxy(&data)
     }
 
     #[test]
     fn test_validate_proxy() {
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -348,17 +348,17 @@ impl<U: WebDriverExtensionRoute> WebDriv
         if requires_body {
             match Json::from_str(body) {
                 Ok(x @ Json::Object(_)) => Ok(x),
                 Ok(_) => {
                     Err(WebDriverError::new(ErrorStatus::InvalidArgument,
                                             "Body was not a JSON Object"))
                 }
                 Err(json::ParserError::SyntaxError(_, line, col)) => {
-                    let msg = format!("Failed to decode request as JSON: \"{}\"", body);
+                    let msg = format!("Failed to decode request as JSON: {}", body);
                     let stack = format!("Syntax error at :{}:{}", line, col);
                     Err(WebDriverError::new_with_stack(ErrorStatus::InvalidArgument, msg, stack))
                 }
                 Err(json::ParserError::IoError(e)) => {
                     Err(WebDriverError::new(ErrorStatus::InvalidArgument,
                                             format!("I/O error whilst decoding body: {}", e)))
                 }
             }