bug 1492499: marionette: empty event queue on window manipulation; r=automatedtester,whimboo

This requests an animation frame off ChromeWindow and waits for
the main thread's event queue to become idle in relation to window
manipulation commands.

It additionally clears the event queue before resizing, because
this is a particularly hazardous operation.  We don't know the
exact science as to why this is needed, so it may just be that this
introduces enough latency for the operation to complete successfully.
File this under "secret sauce".

This ensures all potential synchronisation code between e.g. the
parent process and the child processes have had time to run before
we return from WebDriver:{MinimizeWindow,MaximizeWindow,FullscreenWindow}.

Depends on D8418

Differential Revision: https://phabricator.services.mozilla.com/D8419

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2018-11-08 13:11:28 +00:00
parent d0917b9009
commit de7f55fcf0

View File

@ -1471,6 +1471,7 @@ GeckoDriver.prototype.setWindowRect = async function(cmd) {
win.addEventListener("resize", debounce); win.addEventListener("resize", debounce);
win.addEventListener("resizeEnd", resolve, {once: true}); win.addEventListener("resizeEnd", resolve, {once: true});
win.resizeTo(width, height); win.resizeTo(width, height);
await new IdlePromise(win);
}, {timeout: 5000}); }, {timeout: 5000});
win.removeEventListener("resize", debounce); win.removeEventListener("resize", debounce);
@ -1482,6 +1483,7 @@ GeckoDriver.prototype.setWindowRect = async function(cmd) {
if (win.screenX != x || win.screenY != y) { if (win.screenX != x || win.screenY != y) {
win.moveTo(x, y); win.moveTo(x, y);
await new IdlePromise(win);
} }
} }
@ -2986,6 +2988,7 @@ GeckoDriver.prototype.minimizeWindow = async function() {
win.addEventListener("visibilitychange", resolve, {once: true}); win.addEventListener("visibilitychange", resolve, {once: true});
win.minimize(); win.minimize();
}, {throws: null}); }, {throws: null});
await new IdlePromise(win);
} }
return this.curBrowser.rect; return this.curBrowser.rect;
@ -3032,6 +3035,7 @@ GeckoDriver.prototype.maximizeWindow = async function() {
win.maximize(); win.maximize();
}, {throws: null}); }, {throws: null});
win.removeEventListener("sizemodechange", cb); win.removeEventListener("sizemodechange", cb);
await new IdlePromise(win);
} }
return this.curBrowser.rect; return this.curBrowser.rect;
@ -3073,6 +3077,7 @@ GeckoDriver.prototype.fullscreenWindow = async function() {
}, {throws: null}); }, {throws: null});
win.removeEventListener("sizemodechange", cb); win.removeEventListener("sizemodechange", cb);
} }
await new IdlePromise(win);
return this.curBrowser.rect; return this.curBrowser.rect;
}; };