Bug 1523234 - [marionette] Only focus target window if it isn't already the active window. r=ato
authorHenrik Skupin <mail@hskupin.info>
Thu, 14 Mar 2019 15:14:17 +0000
changeset 524936 2b18f28016cfe2aceb450afb585f8685f07dae5f
parent 524935 97c2ee22169c641e88278fd0801abfc18db6c43f
child 524937 f72d9c9dbcf08cef5872047a16f8c5a0c4876840
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1523234
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1523234 - [marionette] Only focus target window if it isn't already the active window. r=ato Differential Revision: https://phabricator.services.mozilla.com/D23501
testing/marionette/browser.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -324,26 +324,22 @@ browser.Context = class {
 
         // Bug 1509380 - Missing focus/activate event when Firefox is not
         // the top-most application. As such wait for the next tick, and
         // manually focus the newly opened window.
         win.setTimeout(() => win.focus(), 0);
 
         await Promise.all([activated, focused, startup]);
 
-        logger.trace("Opening window is active window: " +
-            `${Services.focus.activeWindow == this.window}`);
-        if (!focus) {
-          // The new window shouldn't get focused. As such set the
-          // focus back to the currently selected window.
+        // The new window shouldn't get focused. As such set the
+        // focus back to the opening window if needed.
+        if (!focus && Services.focus.activeWindow != this.window) {
           activated = waitForEvent(this.window, "activate");
           focused = waitForEvent(this.window, "focus", {capture: true});
 
-          logger.trace("Setting focus back to opening window " +
-              `due to focus: ${focus}`);
           this.window.focus();
 
           await Promise.all([activated, focused]);
         }
 
         return win;
 
       default: