Bug 1378121 - Add Minimize Window command to marionette; r=whimboo, ato draft
authoryangyi_peng@htc.com
Fri, 21 Jul 2017 16:09:58 +0800
changeset 612936 beed33e94190
parent 610282 727bb7860a3d
child 638549 6c68794071f1
push id69654
push userbmo:yangyi_peng@htc.com
push dateFri, 21 Jul 2017 08:10:30 +0000
reviewerswhimboo, ato
bugs1378121
milestone56.0a1
Bug 1378121 - Add Minimize Window command to marionette; r=whimboo, ato MozReview-Commit-ID: K1GSyImGCX3
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/driver.js
testing/marionette/harness/marionette_harness/tests/unit/test_window_minimize.py
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -2039,19 +2039,19 @@ class Marionette(object):
         """
         warnings.warn("set_window_size() has been deprecated, please use set_window_rect()",
                       DeprecationWarning)
         body = {"width": width, "height": height}
         return self._send_message("setWindowSize", body)
 
     def minimize_window(self):
         """ Resize the browser window currently receiving commands. The action
-        should be equivalent to the user pressing the maximize button
+        should be equivalent to the user pressing the minimize button
         """
-        return self._send_message("minimizeWindow")
+        return self._send_message("WebDriver:MinimizeWindow")
 
     def maximize_window(self):
         """ Resize the browser window currently receiving commands. The action
         should be equivalent to the user pressing the maximize button
         """
         return self._send_message("maximizeWindow")
 
     def fullscreen(self):
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2883,32 +2883,35 @@ GeckoDriver.prototype.setScreenOrientati
  * @throws {UnexpectedAlertOpenError}
  *     A modal dialog is open, blocking this operation.
  */
 GeckoDriver.prototype.minimizeWindow = function* (cmd, resp) {
   assert.firefox();
   const win = assert.window(this.getCurrentWindow());
   assert.noUserPrompt(this.dialog);
 
+  let state;
   yield new Promise(resolve => {
     win.addEventListener("sizemodechange", resolve, {once: true});
 
     if (win.windowState == win.STATE_MINIMIZED) {
       win.restore();
+      state = "normal";
     } else {
       win.minimize();
+      state = "minimized";
     }
   });
 
   resp.body = {
     x: win.screenX,
     y: win.screenY,
     width: win.outerWidth,
     height: win.outerHeight,
-    windowState: win.windowState,
+    state: state,
   };
 };
 
 /**
  * Synchronously maximizes the user agent window as if the user pressed
  * the maximize button, or restores it if it is already maximized.
  *
  * Not supported on Fennec.
@@ -3503,17 +3506,16 @@ GeckoDriver.prototype.commands = {
   "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,
-  "minimizeWindow": GeckoDriver.prototype.minimizeWindow,
   "maximizeWindow": GeckoDriver.prototype.maximizeWindow,
   "multiAction": GeckoDriver.prototype.multiAction,
   "newSession": GeckoDriver.prototype.newSession,
   "performActions": GeckoDriver.prototype.performActions,
   "refresh":  GeckoDriver.prototype.refresh,
   "releaseActions": GeckoDriver.prototype.releaseActions,
   "sendKeysToDialog": GeckoDriver.prototype.sendKeysToDialog,
   "sendKeysToElement": GeckoDriver.prototype.sendKeysToElement,
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_window_minimize.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_window_minimize.py
@@ -1,32 +1,28 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from marionette_driver.errors import InvalidArgumentException
 
 from marionette_harness import MarionetteTestCase
 
-WINDOW_MINIMIZED = 2
-WINDOW_NORMAL = 3
-
 class TestWindowMinimize(MarionetteTestCase):
 
     def setUp(self):
         MarionetteTestCase.setUp(self)
-        self.visible = ""
 
         self.original_size = self.marionette.window_size
 
     def assert_window_minimized(self, resp):
-        self.assertEqual(WINDOW_MINIMIZED, resp["windowState"])
+        self.assertEqual("minimized", resp["state"])
 
     def assert_window_restored(self, actual):
-        self.assertEqual(WINDOW_NORMAL, actual["windowState"])
+        self.assertEqual("normal", actual["state"])
         self.assertEqual(self.original_size["width"], actual["width"])
         self.assertEqual(self.original_size["height"], actual["height"])
 
     def test_minimize_twice_restores(self):
         resp = self.marionette.minimize_window()
         self.assert_window_minimized(resp)
 
         # restore the window