mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-12 06:52:25 +00:00
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
This commit is contained in:
parent
f921940bbf
commit
c9ec6362dc
@ -14,6 +14,7 @@ const {
|
||||
UnsupportedOperationError,
|
||||
} = Cu.import("chrome://marionette/content/error.js", {});
|
||||
Cu.import("chrome://marionette/content/frame.js");
|
||||
const {WindowState} = Cu.import("chrome://marionette/content/wm.js", {});
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["browser", "WindowState"];
|
||||
|
||||
@ -451,48 +452,3 @@ browser.Windows = class extends Map {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// TODO(ato): Move this to testing/marionette/wm.js
|
||||
// after https://bugzil.la/1311041
|
||||
/**
|
||||
* Marionette representation of the {@link ChromeWindow} window state.
|
||||
*
|
||||
* @enum {string}
|
||||
*/
|
||||
this.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}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -16,10 +16,7 @@ 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,
|
||||
WindowState,
|
||||
} = Cu.import("chrome://marionette/content/browser.js", {});
|
||||
const {browser} = 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");
|
||||
@ -51,6 +48,7 @@ const {
|
||||
PollPromise,
|
||||
TimedPromise,
|
||||
} = Cu.import("chrome://marionette/content/sync.js", {});
|
||||
const {WindowState} = Cu.import("chrome://marionette/content/wm.js", {});
|
||||
|
||||
Cu.importGlobalProperties(["URL"]);
|
||||
|
||||
|
@ -37,6 +37,7 @@ marionette.jar:
|
||||
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)
|
||||
|
51
testing/marionette/wm.js
Normal file
51
testing/marionette/wm.js
Normal file
@ -0,0 +1,51 @@
|
||||
/* 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;
|
Loading…
x
Reference in New Issue
Block a user