Bug 1294456 - Stop Marionette from being confused about which tab it currently cares about in each window. r?automatedtester
MozReview-Commit-ID: CW0bWILbIuC
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -41,16 +41,22 @@ browser.Context = class {
// used in B2G to identify the homescreen content page
this.mainContentId = null;
// used to set curFrameId upon new session
this.newSession = true;
this.seenEls = new element.Store();
this.setBrowser(win);
// A reference to the tab corresponding to the current window handle, if any.
+ // Specifically, this.tab refers to the last tab that Marionette switched
+ // to in this browser window. Note that this may not equal the currently
+ // selected tab. For example, if Marionette switches to tab A, and then
+ // clicks on a button that opens a new tab B in the same browser window,
+ // this.tab will still point to tab A, despite tab B being the currently
+ // selected tab.
this.tab = null;
this.pendingCommands = [];
// we should have one FM per BO so that we can handle modals in each Browser
this.frameManager = new frame.Manager(driver);
this.frameRegsPending = 0;
// register all message listeners
@@ -209,27 +215,27 @@ browser.Context = class {
/**
* When navigating between pages results in changing a browser's
* process, we need to take measures not to lose contact with a listener
* script. This function does the necessary bookkeeping.
*/
hasRemotenessChange() {
// None of these checks are relevant on b2g or if we don't have a tab yet,
// and may not apply on Fennec.
- if (this.driver.appName != "Firefox" || this.tab === null) {
+ if (this.driver.appName != "Firefox" ||
+ this.tab === null ||
+ this.browserForTab === null) {
return false;
}
if (this._hasRemotenessChange) {
return true;
}
- // this.tab can potentially get stale and cause problems, see bug 1227252
- let currentTab = this.browser.selectedTab;
- let currentIsRemote = this.browser.getBrowserForTab(currentTab).isRemoteBrowser;
+ let currentIsRemote = this.browserForTab.isRemoteBrowser;
this._hasRemotenessChange = this._browserWasRemote !== currentIsRemote;
this._browserWasRemote = currentIsRemote;
return this._hasRemotenessChange;
}
/**
* Flushes any pending commands queued when a remoteness change is being
* processed and mark this remotenessUpdate as complete.