Bug 1348145 - remove getWindowPosition/setWindowPosition and getWindowSize/setWindowSize. r?whimboo draft
authorVenkatesh Pitta <venkateshpitta@gmail.com>
Thu, 12 Apr 2018 12:36:07 +1000
changeset 780902 ac49f2b3137a0d1703f4725d56c41fba9d57d799
parent 780901 14217dd3f65fa477aabe97396784e11f08b7f1e4
child 781511 4b796aba9000f16cb4fc79e9dfb12647dd751a48
push id106157
push userbmo:venkateshpitta@gmail.com
push dateThu, 12 Apr 2018 07:08:57 +0000
reviewerswhimboo
bugs1348145
milestone61.0a1
Bug 1348145 - remove getWindowPosition/setWindowPosition and getWindowSize/setWindowSize. r?whimboo MozReview-Commit-ID: 8mftbz7rUVC
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1369,35 +1369,16 @@ class Marionette(object):
 
         :returns: unique window handle
         :rtype: string
         """
         self.chrome_window = self._send_message(
             "getCurrentChromeWindowHandle", key="value")
         return self.chrome_window
 
-    def get_window_position(self):
-        """Get the current window's position.
-
-        :returns: a dictionary with x and y
-        """
-        warnings.warn("get_window_position() has been deprecated, please use get_window_rect()",
-                      DeprecationWarning)
-        return self._send_message("getWindowPosition")
-
-    def set_window_position(self, x, y):
-        """Set the position of the current window
-
-        :param x: x coordinate for the top left of the window
-        :param y: y coordinate for the top left of the window
-        """
-        warnings.warn("set_window_position() has been deprecated, please use set_window_rect()",
-                      DeprecationWarning)
-        self._send_message("setWindowPosition", {"x": x, "y": y})
-
     def set_window_rect(self, x=None, y=None, height=None, width=None):
         """Set the position and size of the current window.
 
         The supplied width and height values refer to the window outerWidth
         and outerHeight values, which include scroll bars, title bars, etc.
 
         An error will be returned if the requested window size would result
         in the window being in the maximised state.
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -3619,17 +3619,16 @@ GeckoDriver.prototype.commands = {
   "getPageSource": GeckoDriver.prototype.getPageSource,
   "getScreenOrientation": GeckoDriver.prototype.getScreenOrientation,
   "getSessionCapabilities": GeckoDriver.prototype.getSessionCapabilities,
   "getTextFromDialog": GeckoDriver.prototype.getTextFromDialog,
   "getTimeouts": GeckoDriver.prototype.getTimeouts,
   "getTitle": GeckoDriver.prototype.getTitle,
   "getWindowHandle": GeckoDriver.prototype.getWindowHandle,
   "getWindowHandles": GeckoDriver.prototype.getWindowHandles,
-  "getWindowPosition": GeckoDriver.prototype.getWindowRect, // redirect for compatibility
   "getWindowRect": GeckoDriver.prototype.getWindowRect,
   "getWindowSize": GeckoDriver.prototype.getWindowRect, // redirect for compatibility
   "getWindowType": GeckoDriver.prototype.getWindowType,
   "goBack": GeckoDriver.prototype.goBack,
   "goForward": GeckoDriver.prototype.goForward,
   "isElementDisplayed": GeckoDriver.prototype.isElementDisplayed,
   "isElementEnabled": GeckoDriver.prototype.isElementEnabled,
   "isElementSelected": GeckoDriver.prototype.isElementSelected,
@@ -3638,17 +3637,16 @@ GeckoDriver.prototype.commands = {
   "newSession": GeckoDriver.prototype.newSession,
   "performActions": GeckoDriver.prototype.performActions,
   "refresh":  GeckoDriver.prototype.refresh,
   "releaseActions": GeckoDriver.prototype.releaseActions,
   "sendKeysToDialog": GeckoDriver.prototype.sendKeysToDialog,
   "sendKeysToElement": GeckoDriver.prototype.sendKeysToElement,
   "setScreenOrientation": GeckoDriver.prototype.setScreenOrientation,
   "setTimeouts": GeckoDriver.prototype.setTimeouts,
-  "setWindowPosition": GeckoDriver.prototype.setWindowRect, // redirect for compatibility
   "setWindowRect": GeckoDriver.prototype.setWindowRect,
   "setWindowSize": GeckoDriver.prototype.setWindowRect, // redirect for compatibility
   "singleTap": GeckoDriver.prototype.singleTap,
   "switchToFrame": GeckoDriver.prototype.switchToFrame,
   "switchToParentFrame": GeckoDriver.prototype.switchToParentFrame,
   "switchToShadowRoot": GeckoDriver.prototype.switchToShadowRoot,
   "switchToWindow": GeckoDriver.prototype.switchToWindow,
   "takeScreenshot": GeckoDriver.prototype.takeScreenshot,
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_rect.py
@@ -7,70 +7,82 @@ from __future__ import absolute_import, 
 from marionette_driver.errors import InvalidArgumentException
 from marionette_harness import MarionetteTestCase
 
 
 class TestPosition(MarionetteTestCase):
 
     def setUp(self):
         MarionetteTestCase.setUp(self)
-        self.original_position = self.marionette.get_window_position()
+        self.original_position = self.marionette.window_rect
 
     def tearDown(self):
         x, y = self.original_position["x"], self.original_position["y"]
-        self.marionette.set_window_position(x, y)
+        height, width = self.original_position["height"], self.original_position["width"]
+        self.marionette.set_window_rect(x, y, height, width)
         MarionetteTestCase.tearDown(self)
 
     def test_get_types(self):
-        position = self.marionette.get_window_position()
+        position = self.marionette.window_rect
         self.assertIn("x", position)
         self.assertIn("y", position)
+        self.assertIn("height", position)
+        self.assertIn("width", position)
         self.assertIsInstance(position["x"], int)
         self.assertIsInstance(position["y"], int)
+        self.assertIsInstance(position["height"], int)
+        self.assertIsInstance(position["width"], int)
 
     def test_set_types(self):
-        for x, y in (["a", "b"], [1.2, 3.4], [True, False], [[], []], [{}, {}]):
+        for x, y, h, w in (["a", "b", "h", "w"], [1.2, 3.4, 4.5, 5.6],
+                           [True, False, True, False], [[], [], [], []],
+                           [{}, {}, {}, {}]):
             print("testing invalid type position ({},{})".format(x, y))
             with self.assertRaises(InvalidArgumentException):
-                self.marionette.set_window_position(x, y)
+                self.marionette.set_window_rect(x, y, h, w)
 
     def test_setting_window_rect_with_nulls_errors(self):
         with self.assertRaises(InvalidArgumentException):
             self.marionette.set_window_rect(height=None, width=None,
                                             x=None, y=None)
 
     def test_set_position_with_rect(self):
         old_position = self.marionette.window_rect
         wanted_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10}
 
         new_position = self.marionette.set_window_rect(x=wanted_position["x"], y=wanted_position["y"])
 
         self.assertNotEqual(old_position["x"], new_position["x"])
         self.assertNotEqual(old_position["y"], new_position["y"])
 
     def test_move_to_new_position(self):
-        old_position = self.marionette.get_window_position()
+        old_position = self.marionette.window_rect
         new_position = {"x": old_position["x"] + 10, "y": old_position["y"] + 10}
-        self.marionette.set_window_position(new_position["x"], new_position["y"])
+        self.marionette.set_window_rect(new_position["x"], new_position["y"])
         self.assertNotEqual(old_position["x"], new_position["x"])
         self.assertNotEqual(old_position["y"], new_position["y"])
 
     def test_move_to_existing_position(self):
-        old_position = self.marionette.get_window_position()
-        self.marionette.set_window_position(old_position["x"], old_position["y"])
-        new_position = self.marionette.get_window_position()
+        old_position = self.marionette.window_rect
+        self.marionette.set_window_rect(old_position["x"], old_position["y"],
+                                        old_position["height"], old_position["width"])
+        new_position = self.marionette.window_rect
         self.assertEqual(old_position["x"], new_position["x"])
         self.assertEqual(old_position["y"], new_position["y"])
+        self.assertEqual(old_position["height"], new_position["height"])
+        self.assertEqual(old_position["width"], new_position["width"])
 
     def test_move_to_negative_coordinates(self):
+        dims = self.marionette.window_rect
         print("Current position: {}".format(
-            self.marionette.get_window_position()))
-        self.marionette.set_window_position(-8, -8)
-        position = self.marionette.get_window_position()
-        print("Position after requesting move to negative coordinates: {}".format(position))
+            dims["x"], dims["y"]))
+        self.marionette.set_window_rect(-8, -8)
+        position = self.marionette.window_rect
+        print("Position after requesting move to negative coordinates: {}, {}"
+              .format(position))
 
         # Different systems will report more or less than (-8,-8)
         # depending on the characteristics of the window manager, since
         # the screenX/screenY position measures the chrome boundaries,
         # including any WM decorations.
         #
         # This makes this hard to reliably test across different
         # environments.  Generally we are happy when calling