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
--- 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);
}