Bug 1388036 - Restore window when setting window rect. r?automatedtester
If the window is minimized when setting the window rect, restore it
before resizing or moving the window. We already exit fullscreen,
so this brings parity to the WebDriver:SetWindowRect command.
MozReview-Commit-ID: KrvWJjKX1eA
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1502,16 +1502,24 @@ GeckoDriver.prototype.setWindowRect = as
// Exit fullscreen and wait for window to resize.
async function exitFullscreen() {
return new Promise(resolve => {
win.addEventListener("sizemodechange", optimisedResize(resolve), {once: true});
win.fullScreen = false;
});
}
+ // Restore window and wait for the window state to change.
+ async function restoreWindow() {
+ return new Promise(resolve => {
+ win.addEventListener("sizemodechange", resolve, {once: true});
+ win.restore();
+ });
+ }
+
// Synchronous resize to |width| and |height| dimensions.
async function resizeWindow(width, height) {
return new Promise(resolve => {
win.addEventListener("resize", optimisedResize(resolve), {once: true});
win.resizeTo(width, height);
});
}
@@ -1537,18 +1545,24 @@ GeckoDriver.prototype.setWindowRect = as
(win.screenX != origRect.x || win.screenY != origRect.y)) {
resolve();
} else {
reject();
}
});
}
- if (win.windowState == win.STATE_FULLSCREEN) {
- await exitFullscreen();
+ switch (win.windowState) {
+ case win.STATE_FULLSCREEN:
+ await exitFullscreen();
+ break;
+
+ case win.STATE_MINIMIZED:
+ await restoreWindow();
+ break;
}
if (height != null && width != null) {
assert.positiveInteger(height);
assert.positiveInteger(width);
if (win.outerWidth != width || win.outerHeight != height) {
await resizeWindow(width, height);