Bug 1431155 - Move WindowState to Marionette browser module. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 17 Jan 2018 17:56:25 +0000
changeset 722182 63cac2b0f1ad48922dc95fb5e8c99d36333ae9a1
parent 722181 0a543687fd36bc0dc4188c3d33d117b0a8174721
child 746547 e314f0a5752beb366978ef187b022382975e58f1
push id96076
push userbmo:ato@sny.no
push dateThu, 18 Jan 2018 15:48:22 +0000
reviewersautomatedtester
bugs1431155
milestone59.0a1
Bug 1431155 - Move WindowState to Marionette browser module. r?automatedtester This moves the WindowState enum from testing/marionette/wm.js to testing/marionette/browser.js in order to make it easier to apply the forthcoming Marionette window tracking refactoring patches. In other words, this patch functionally does not change anything. MozReview-Commit-ID: 53MKIRHl11p
testing/marionette/browser.js
testing/marionette/driver.js
testing/marionette/jar.mn
testing/marionette/wm.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -8,17 +8,16 @@
 const {utils: Cu} = Components;
 
 const {WebElementEventTarget} = Cu.import("chrome://marionette/content/dom.js", {});
 Cu.import("chrome://marionette/content/element.js");
 const {
   NoSuchWindowError,
   UnsupportedOperationError,
 } = Cu.import("chrome://marionette/content/error.js", {});
-const {WindowState} = Cu.import("chrome://marionette/content/wm.js", {});
 
 this.EXPORTED_SYMBOLS = ["browser", "Context", "WindowState"];
 
 /** @namespace */
 this.browser = {};
 
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
@@ -492,8 +491,52 @@ browser.Windows = class extends Map {
     let wref = super.get(id);
     if (!wref) {
       throw new RangeError();
     }
     return wref.get();
   }
 
 };
+
+/**
+ * Marionette representation of the {@link ChromeWindow} window state.
+ *
+ * @enum {string}
+ */
+const WindowState = {
+  Maximized: "maximized",
+  Minimized: "minimized",
+  Normal: "normal",
+  Fullscreen: "fullscreen",
+
+  /**
+   * Converts {@link nsIDOMChromeWindow.windowState} to WindowState.
+   *
+   * @param {number} windowState
+   *     Attribute from {@link nsIDOMChromeWindow.windowState}.
+   *
+   * @return {WindowState}
+   *     JSON representation.
+   *
+   * @throws {TypeError}
+   *     If <var>windowState</var> was unknown.
+   */
+  from(windowState) {
+    switch (windowState) {
+      case 1:
+        return WindowState.Maximized;
+
+      case 2:
+        return WindowState.Minimized;
+
+      case 3:
+        return WindowState.Normal;
+
+      case 4:
+        return WindowState.Fullscreen;
+
+      default:
+        throw new TypeError(`Unknown window state: ${windowState}`);
+    }
+  },
+};
+this.WindowState = WindowState;
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -14,16 +14,17 @@ Cu.import("resource://gre/modules/XPCOMU
 
 Cu.import("chrome://marionette/content/accessibility.js");
 Cu.import("chrome://marionette/content/addon.js");
 Cu.import("chrome://marionette/content/assert.js");
 Cu.import("chrome://marionette/content/atom.js");
 const {
   browser,
   Context,
+  WindowState,
 } = Cu.import("chrome://marionette/content/browser.js", {});
 Cu.import("chrome://marionette/content/capture.js");
 Cu.import("chrome://marionette/content/cert.js");
 Cu.import("chrome://marionette/content/cookie.js");
 const {
   ChromeWebElement,
   element,
   WebElement,
@@ -48,17 +49,16 @@ Cu.import("chrome://marionette/content/l
 Cu.import("chrome://marionette/content/modal.js");
 Cu.import("chrome://marionette/content/proxy.js");
 Cu.import("chrome://marionette/content/reftest.js");
 Cu.import("chrome://marionette/content/session.js");
 const {
   PollPromise,
   TimedPromise,
 } = Cu.import("chrome://marionette/content/sync.js", {});
-const {WindowState} = Cu.import("chrome://marionette/content/wm.js", {});
 
 Cu.importGlobalProperties(["URL"]);
 
 this.EXPORTED_SYMBOLS = ["GeckoDriver"];
 
 const APP_ID_FIREFOX = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
 const FRAME_SCRIPT = "chrome://marionette/content/listener.js";
--- a/testing/marionette/jar.mn
+++ b/testing/marionette/jar.mn
@@ -31,17 +31,16 @@ marionette.jar:
   content/session.js (session.js)
   content/transport.js (transport.js)
   content/packets.js (packets.js)
   content/stream-utils.js (stream-utils.js)
   content/reftest.js (reftest.js)
   content/reftest.xul (reftest.xul)
   content/dom.js (dom.js)
   content/format.js (format.js)
-  content/wm.js (wm.js)
 #ifdef ENABLE_TESTS
   content/test.xul (chrome/test.xul)
   content/test2.xul (chrome/test2.xul)
   content/test_dialog.dtd (chrome/test_dialog.dtd)
   content/test_dialog.properties (chrome/test_dialog.properties)
   content/test_dialog.xul (chrome/test_dialog.xul)
   content/test_nested_iframe.xul (chrome/test_nested_iframe.xul)
   content/test_anonymous_content.xul (chrome/test_anonymous_content.xul)
--- a/testing/marionette/wm.js
+++ b/testing/marionette/wm.js
@@ -1,51 +1,7 @@
 /* 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/. */
 
 "use strict";
 
-this.EXPORTED_SYMBOLS = ["WindowState"];
-
-/**
- * Marionette representation of the {@link ChromeWindow} window state.
- *
- * @enum {string}
- */
-const WindowState = {
-  Maximized: "maximized",
-  Minimized: "minimized",
-  Normal: "normal",
-  Fullscreen: "fullscreen",
-
-  /**
-   * Converts {@link nsIDOMChromeWindow.windowState} to WindowState.
-   *
-   * @param {number} windowState
-   *     Attribute from {@link nsIDOMChromeWindow.windowState}.
-   *
-   * @return {WindowState}
-   *     JSON representation.
-   *
-   * @throws {TypeError}
-   *     If <var>windowState</var> was unknown.
-   */
-  from(windowState) {
-    switch (windowState) {
-      case 1:
-        return WindowState.Maximized;
-
-      case 2:
-        return WindowState.Minimized;
-
-      case 3:
-        return WindowState.Normal;
-
-      case 4:
-        return WindowState.Fullscreen;
-
-      default:
-        throw new TypeError(`Unknown window state: ${windowState}`);
-    }
-  },
-};
-this.WindowState = WindowState;
+this.EXPORTED_SYMBOLS = [];