Bug 1283959 - Add SetWindowSize to return new width and height to comply with WD Spec draft
authorNelson João Morais <njmorais@gmail.com>
Thu, 14 Jul 2016 01:11:07 +0100
changeset 387561 441e7a86aa52038fafb1731f88b45e2dc7f85d1a
parent 386010 679118259e91f40d4a8f968f03ec4cff066cdb5b
child 525381 37ad27a9e897a698652528636c79cb260dc92fe3
push id22994
push userbmo:njmorais@gmail.com
push dateThu, 14 Jul 2016 08:38:23 +0000
bugs1283959
milestone50.0a1
Bug 1283959 - Add SetWindowSize to return new width and height to comply with WD Spec MozReview-Commit-ID: AGnJuLqyULY
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/driver.js
testing/marionette/harness/marionette/tests/unit/test_set_window_size.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1929,15 +1929,15 @@ class Marionette(object):
         An error will be returned if the requested window size would result
         in the window being in the maximised state.
 
         :param width: The width to resize the window to.
         :param height: The height to resize the window to.
 
         """
         body = {"width": width, "height": height}
-        self._send_message("setWindowSize", body)
+        return self._send_message("setWindowSize", body)
 
     def maximize_window(self):
         """ Resize the browser window currently receiving commands. The action
         should be equivalent to the user pressing the the maximize button
         """
         return self._send_message("maximizeWindow")
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2487,16 +2487,17 @@ GeckoDriver.prototype.getWindowSize = fu
 GeckoDriver.prototype.setWindowSize = function(cmd, resp) {
   if (this.appName != "Firefox") {
     throw new UnsupportedOperationError();
   }
 
   let {width, height} = cmd.parameters;
   let win = this.getCurrentWindow();
   win.resizeTo(width, height);
+  this.getWindowSize(cmd, resp);
 };
 
 /**
  * Maximizes the user agent window as if the user pressed the maximise
  * button.
  *
  * Not Supported on B2G or Fennec.
  */
--- a/testing/marionette/harness/marionette/tests/unit/test_set_window_size.py
+++ b/testing/marionette/harness/marionette/tests/unit/test_set_window_size.py
@@ -38,16 +38,27 @@ class TestSetWindowSize(MarionetteTestCa
         self.marionette.set_window_size(width, height)
         self.wait_for_condition(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_event;"))
         size = self.marionette.window_size
         self.assertEqual(size['width'], width,
                          "Window width is %s but should be %s" % (size['width'], width))
         self.assertEqual(size['height'], height,
                          "Window height is %s but should be %s" % (size['height'], height))
 
+    def test_that_we_can_get_new_size_when_set_window_size(self):
+        actual = self.marionette.window_size
+        width = actual['width'] - 50
+        height = actual['height'] - 50
+        size = self.marionette.set_window_size(width, height)
+        self.assertIsNotNone(size, "Response is None")
+        self.assertEqual(size['width'], width,
+                         "New width is %s but should be %s" % (size['width'], width))
+        self.assertEqual(size['height'], height,
+                         "New height is %s but should be %s" % (size['height'], height))
+
     def test_possible_to_request_window_larger_than_screen(self):
         self.marionette.set_window_size(100000, 100000)
         size = self.marionette.window_size
 
         # In X the window size may be greater than the bounds of the screen
         self.assertGreaterEqual(size["width"], self.max_width)
         self.assertGreaterEqual(size["height"], self.max_height)