From aeb2acfd24cd72a1c3b3ec0fdf9cfa5dba18ada6 Mon Sep 17 00:00:00 2001 From: Andreas Tolfsen Date: Thu, 8 Nov 2018 13:11:18 +0000 Subject: [PATCH] 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 --- testing/marionette/driver.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/marionette/driver.js b/testing/marionette/driver.js index 7e2e45bcfffb..2125feb06d65 100644 --- a/testing/marionette/driver.js +++ b/testing/marionette/driver.js @@ -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;