Bug 1423358 - Disassociate frameRegsPending from curBrowser. r?whimboo
This moves the frameRegsPending state from browser.Context (curBrowser)
to GeckoDriver. This probably isn't the ideal place for it either,
but will make it easier for the window tracking refactoring to
remove browser.Context in its entirety.
MozReview-Commit-ID: Cf8DAShW2ys
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -149,17 +149,16 @@ browser.Context = class {
// been fully processed. The commands get flushed after a new browser
// has been registered.
this.pendingCommands = [];
this._needsFlushPendingCommands = false;
// We should have one frame.Manager per browser.Context so that we
// can handle modals in each <xul:browser>.
this.frameManager = new frame.Manager(driver);
- this.frameRegsPending = 0;
// register all message listeners
this.frameManager.addMessageManagerListeners(driver.mm);
this.getIdForBrowser = driver.getIdForBrowser.bind(driver);
this.updateIdForBrowser = driver.updateIdForBrowser.bind(driver);
}
/**
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -133,16 +133,17 @@ this.GeckoDriver = function(appId, serve
// points to current browser
this.curBrowser = null;
// topmost chrome frame
this.mainFrame = null;
// chrome iframe that currently has focus
this.curFrame = null;
this.mozBrowserClose = null;
this.currentFrameElement = null;
+ this.frameRegsPending = 0;
// frame ID of the current remote frame, used for mozbrowserclose events
this.oopFrameId = null;
this.observing = null;
this._browserIds = new WeakMap();
// The curent context decides if commands should affect chrome- or
// content space.
this.context = Context.Content;
@@ -499,20 +500,20 @@ GeckoDriver.prototype.whenBrowserStarted
// return to the server. If the messageManager is a message broadcaster
// with no children, we don't have a hope of coming back from this
// call, so send the ack here. Otherwise, make a note of how many
// child scripts will be loaded so we known when it's safe to return.
// Child managers may not have child scripts yet (e.g. socialapi),
// only count child managers that have children, but only count the top
// level children as they are the ones that we expect a response from.
if (mm.childCount !== 0) {
- this.curBrowser.frameRegsPending = 0;
+ this.frameRegsPending = 0;
for (let i = 0; i < mm.childCount; i++) {
if (mm.getChildAt(i).childCount !== 0) {
- this.curBrowser.frameRegsPending += 1;
+ this.frameRegsPending += 1;
}
}
}
}
if (!Preferences.get(CONTENT_LISTENER_PREF) || !isNewSession) {
// load listener into the remote frame
// and any applicable new frames
@@ -605,21 +606,21 @@ GeckoDriver.prototype.registerPromise =
const li = "Marionette:register";
return new Promise(resolve => {
let cb = msg => {
let wid = msg.json.value;
let be = msg.target;
let rv = this.registerBrowser(wid, be);
- if (this.curBrowser.frameRegsPending > 0) {
- this.curBrowser.frameRegsPending--;
+ if (this.frameRegsPending > 0) {
+ this.frameRegsPending--;
}
- if (this.curBrowser.frameRegsPending === 0) {
+ if (this.frameRegsPending === 0) {
this.mm.removeMessageListener(li, cb);
resolve();
}
// this is a sync message and listeners expect the ID back
return rv;
};
this.mm.addMessageListener(li, cb);