gecko-dev/testing/marionette/wm.js
Andreas Tolfsen c9ec6362dc Bug 1409379 - Move WindowState to new wm module. r=maja_zf
The upcoming window tracking refactoring to Marionette will introduce
a new testing/marionette/wm.js module.  It was originally the plan
to move WindowState there after it had landed, but it actually makes
sense to land any dependencies before to reduce churn in the window
tracking patches.

MozReview-Commit-ID: EpqnTYYGcmg

--HG--
extra : rebase_source : d6760feefa49c522738fd3930b339bc0af70e6a5
2017-10-17 14:20:52 +01:00

52 lines
1.2 KiB
JavaScript

/* 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;