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 521938 2b18f28016cf
parent 521937 97c2ee22169c
child 521939 f72d9c9dbcf0
push id10870
push usernbeleuzu@mozilla.com
push dateFri, 15 Mar 2019 20:00:07 +0000
treeherdermozilla-beta@c594aee5b7a4 [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: