Bug 1332122 - Remove unnecessary wrapper browser.startSession(). draft
authorHenrik Skupin <mail@hskupin.info>
Tue, 04 Jul 2017 10:27:54 +0200
changeset 604647 0ba79dd1bafde54e1f21fb24dff22de46d84bbf7
parent 604481 af0466865a212c84fbbab343c9cbb984c6132920
child 604648 38f2c0fe916e84bd567b94e1b4fd62c537ff5cbc
child 604891 51dceb7d83fa029fa21fbe6676f3e7772ee14c3b
push id67148
push userbmo:hskupin@gmail.com
push dateThu, 06 Jul 2017 08:05:07 +0000
bugs1332122
milestone56.0a1
Bug 1332122 - Remove unnecessary wrapper browser.startSession(). This wrapper just calls back into the MarionetteDriver, and doesn't have any value. Removing it simplifies the call stack. MozReview-Commit-ID: GH1xUHX12Xi
testing/marionette/browser.js
testing/marionette/driver.js
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -229,21 +229,16 @@ browser.Context = class {
     return new Promise(resolve => {
       this.window.addEventListener("unload", ev => {
         resolve();
       }, {once: true});
       this.window.close();
     });
   }
 
-  /** Called when we start a session with this browser. */
-  startSession(newSession, win, callback) {
-    callback(win, newSession);
-  }
-
   /**
    * Close the current tab.
    *
    * @return {Promise}
    *     A promise which is resolved when the current tab has been closed.
    *
    * @throws UnsupportedOperationError
    *     If tab handling for the current application isn't supported.
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -468,18 +468,17 @@ GeckoDriver.prototype.addBrowser = funct
  * @param {boolean=false} isNewSession
  *     True if this is the first time we're talking to this browser.
  */
 GeckoDriver.prototype.startBrowser = function(win, isNewSession = false) {
   this.mainFrame = win;
   this.curFrame = null;
   this.addBrowser(win);
   this.curBrowser.isNewSession = isNewSession;
-  this.curBrowser.startSession(
-      isNewSession, win, this.whenBrowserStarted.bind(this));
+  this.whenBrowserStarted(win, isNewSession);
 };
 
 /**
  * Callback invoked after a new session has been started in a browser.
  * Loads the Marionette frame script into the browser if needed.
  *
  * @param {nsIDOMWindow} win
  *     Window whose browser we need to access.
@@ -703,18 +702,19 @@ GeckoDriver.prototype.newSession = funct
       this.startBrowser(win, true);
     }
   };
 
   if (!Preferences.get(CONTENT_LISTENER_PREF)) {
     waitForWindow.call(this);
   } else if (this.appName != "Firefox" && this.curBrowser === null) {
     // if there is a content listener, then we just wake it up
-    this.addBrowser(this.getCurrentWindow());
-    this.curBrowser.startSession(this.whenBrowserStarted.bind(this));
+    let win = this.getCurrentWindow();
+    this.addBrowser(win);
+    this.whenBrowserStarted(win, false);
     this.mm.broadcastAsyncMessage("Marionette:restart", {});
   } else {
     throw new WebDriverError("Session already running");
   }
   this.switchToGlobalMessageManager();
 
   yield registerBrowsers;
   yield browserListening;