Bug 1363428 - Handle top level reftest window specially in Marionette, r=ato draft
authorJames Graham <james@hoppipolla.co.uk>
Tue, 09 May 2017 19:05:49 +0100
changeset 600210 875d7c1bc9eef5b6454794ba7a2ce2018a559554
parent 600209 a12822b629b373cb3e4f505f697beaed31f08254
child 600211 637b01884025ad9a7fb409082eabff52f4434af5
push id65688
push userbmo:james@hoppipolla.co.uk
push dateSat, 24 Jun 2017 11:04:46 +0000
reviewersato
bugs1363428
milestone56.0a1
Bug 1363428 - Handle top level reftest window specially in Marionette, r=ato Because this window is a normal Firefox window but doesn't contain any tabs, the normal Marionette functions for iterating over windows don't work well. As a sort of hack, identify this window by the id of its root element, and special case it when finding windows in Marionette. MozReview-Commit-ID: LxPv13YDXDu
testing/marionette/browser.js
testing/marionette/driver.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -121,29 +121,31 @@ browser.Context = class {
 
   /**
    * Returns the content browser for the currently selected tab.
    * If there is no tab selected, null will be returned.
    */
   get contentBrowser() {
     if (this.tab) {
       return browser.getBrowserForTab(this.tab);
+    } else if (this.tabBrowser && this.driver.isReftestBrowser(this.tabBrowser)) {
+      return this.tabBrowser;
     }
 
     return null;
   }
 
   /**
    * The current frame ID is managed per browser element on desktop in
    * case the ID needs to be refreshed. The currently selected window is
    * identified by a tab.
    */
   get curFrameId() {
     let rv = null;
-    if (this.tab) {
+     if (this.tab || this.driver.isReftestBrowser(this.contentBrowser) ) {
       rv = this.getIdForBrowser(this.contentBrowser);
     }
     return rv;
   }
 
   /**
    * Returns the current URI of the content browser.
    *
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -362,27 +362,33 @@ GeckoDriver.prototype.getCurrentWindow =
         win = this.curBrowser.window;
       }
 
       break;
 
     case Context.CONTENT:
       if (this.curFrame !== null) {
         win = this.curFrame;
-
       } else if (this.curBrowser !== null && this.curBrowser.contentBrowser) {
-          win = this.curBrowser.window;
+        win = this.curBrowser.window;
       }
-
       break;
   }
 
   return win;
 };
 
+GeckoDriver.prototype.isReftestBrowser = function (element) {
+  return this._reftest &&
+    element &&
+    element.tagName === "xul:browser" &&
+    element.parentElement &&
+    element.parentElement.id === "reftest";
+}
+
 GeckoDriver.prototype.addFrameCloseListener = function (action) {
   let win = this.getCurrentWindow();
   this.mozBrowserClose = e => {
     if (e.target.id == this.oopFrameId) {
       win.removeEventListener("mozbrowserclose", this.mozBrowserClose, true);
       this.switchToGlobalMessageManager();
       throw new NoSuchWindowError("The window closed during action: " + action);
     }