Bug 1423358 - Disassociate frameRegsPending from curBrowser. r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Tue, 05 Dec 2017 22:05:39 +0000
changeset 707862 973a7cbd1e13e6fa4a8434bd146d147a1cb7ca43
parent 707853 18a9cb5cb32d0e8031d0a80901b199d5e9827d83
child 743050 fe383388db88c007ad0f9b803d6de0f401ea5385
push id92234
push userbmo:ato@sny.no
push dateTue, 05 Dec 2017 22:07:01 +0000
reviewerswhimboo
bugs1423358
milestone59.0a1
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
testing/marionette/browser.js
testing/marionette/driver.js
--- 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);