Bug 1494637 - [geckodriver] Only serialize non null arguments for Marionette. r=ato
authorHenrik Skupin <mail@hskupin.info>
Sat, 29 Sep 2018 15:34:38 +0000
changeset 494617 77cf6aa75d7ebe8c871cd1fe5736d47b92e999e5
parent 494616 95c3fa4ad4d45a11e08c6136e0ec5008ff19ec1f
child 494618 c3af1b427280554e9887d109eb2eff74a7255b27
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1494637
milestone64.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
Bug 1494637 - [geckodriver] Only serialize non null arguments for Marionette. r=ato Differential Revision: https://phabricator.services.mozilla.com/D7210
testing/geckodriver/src/marionette.rs
testing/webdriver/src/command.rs
--- a/testing/geckodriver/src/marionette.rs
+++ b/testing/geckodriver/src/marionette.rs
@@ -1401,17 +1401,16 @@ impl ToMarionette for GetParameters {
     }
 }
 
 impl ToMarionette for JavascriptCommandParameters {
     fn to_marionette(&self) -> WebDriverResult<Map<String, Value>> {
         let mut data = serde_json::to_value(self)?.as_object().unwrap().clone();
         data.insert("newSandbox".to_string(), Value::Bool(false));
         data.insert("specialPowers".to_string(), Value::Bool(false));
-        data.insert("scriptTimeout".to_string(), Value::Null);
         Ok(data)
     }
 }
 
 impl ToMarionette for LocatorParameters {
     fn to_marionette(&self) -> WebDriverResult<Map<String, Value>> {
         Ok(try_opt!(
             serde_json::to_value(self)?.as_object(),
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -541,23 +541,39 @@ where
 /// In some user agents the operating system’s window dimensions, including
 /// decorations, are provided by the proprietary `window.outerWidth` and
 /// `window.outerHeight` DOM properties.
 ///
 /// [`screenX`]: https://w3c.github.io/webdriver/webdriver-spec.html#dfn-screenx
 /// [`screenY`]: https://w3c.github.io/webdriver/webdriver-spec.html#dfn-screeny
 #[derive(Debug, PartialEq, Serialize, Deserialize)]
 pub struct WindowRectParameters {
-    #[serde(default, deserialize_with = "deserialize_to_i32")]
+    #[serde(
+        default,
+        skip_serializing_if = "Option::is_none",
+        deserialize_with = "deserialize_to_i32"
+    )]
     pub x: Option<i32>,
-    #[serde(default, deserialize_with = "deserialize_to_i32")]
+    #[serde(
+        default,
+        skip_serializing_if = "Option::is_none",
+        deserialize_with = "deserialize_to_i32"
+    )]
     pub y: Option<i32>,
-    #[serde(default, deserialize_with = "deserialize_to_positive_i32")]
+    #[serde(
+        default,
+        skip_serializing_if = "Option::is_none",
+        deserialize_with = "deserialize_to_positive_i32"
+    )]
     pub width: Option<i32>,
-    #[serde(default, deserialize_with = "deserialize_to_positive_i32")]
+    #[serde(
+        default,
+        skip_serializing_if = "Option::is_none",
+        deserialize_with = "deserialize_to_positive_i32"
+    )]
     pub height: Option<i32>,
 }
 
 fn deserialize_to_i32<'de, D>(deserializer: D) -> Result<Option<i32>, D::Error>
 where
     D: Deserializer<'de>,
 {
     let opt = Option::deserialize(deserializer)?.map(|value: f64| value as i64);