bug 1492499: marionette: bail if visibilitychange does not fire on minimization; r=whimboo

The visibilitychange DOM event does not fire reliably in all
configurations when retrieved from web content.  It appears to fire more
reliably in chrome, but to ensure a call to WebDriver:MinimizeWindow
never hangs, we additionally change it to be a TimedPromise.

There is an assumption here that if the iconification process does
not complete within this duration, there is nothing we can do.

Depends on D8413

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2018-11-08 13:11:18 +00:00
Родитель 3d84531a75
Коммит aeb2acfd24
1 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -3000,15 +3000,15 @@ GeckoDriver.prototype.minimizeWindow = async function() {
const win = assert.open(this.getCurrentWindow());
await this._handleUserPrompts();
if (WindowState.from(win.windowState) == WindowState.Fullscreen) {
await exitFullscreen(win);
}
if (WindowState.from(win.windowState) != WindowState.Minimized) {
await new Promise(resolve => {
this.curBrowser.eventObserver.addEventListener("visibilitychange", resolve, {once: true});
if (WindowState.from(win.windowState) == WindowState.Fullscreen) {
await exitFullscreen(win);
}
await new TimedPromise(resolve => {
win.addEventListener("visibilitychange", resolve, {once: true});
win.minimize();
});
}, {throws: null});
}
return this.curBrowser.rect;