Bug 787203: Get Marionette working in Fennec draft
authorDavid Burns <dburns@mozilla.com>
Tue, 01 Mar 2016 21:06:29 +0000
changeset 338966 174a36b37c6d9838a28257e5c26531721296b589
parent 338965 25a61e969b4ea97f727d5711577a826a9733261a
child 515892 0a22950d318c810044a9b467a5cd468871f8000e
push id12619
push userdburns@mozilla.com
push dateThu, 10 Mar 2016 09:00:57 +0000
bugs787203
milestone48.0a1
Bug 787203: Get Marionette working in Fennec MozReview-Commit-ID: D5sFULBOdcU
mobile/android/app/mobile.js
testing/marionette/driver.js
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -14,16 +14,21 @@
 //
 // For instance: cachePercentageWidth is 1500
 //               viewport height is 500
 //               => display port height will be 500 * 1.5 = 750
 //
 pref("toolkit.browser.cacheRatioWidth", 2000);
 pref("toolkit.browser.cacheRatioHeight", 3000);
 
+//marionette to be removed
+
+pref("marionette.defaultPrefs.enabled", true);
+pref("marionette.defaultPrefs.port", 2828);
+
 // How long before a content view (a handle to a remote scrollable object)
 // expires.
 pref("toolkit.browser.contentViewExpire", 3000);
 
 pref("toolkit.defaultChromeURI", "chrome://browser/content/browser.xul");
 pref("browser.chromeURL", "chrome://browser/content/");
 
 // If a tab has not been active for this long (seconds), then it may be
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -1499,39 +1499,39 @@ GeckoDriver.prototype.setWindowPosition 
  * Switch current top-level browsing context by name or server-assigned ID.
  * Searches for windows by name, then ID.  Content windows take precedence.
  *
  * @param {string} name
  *     Target name or ID of the window to switch to.
  */
 GeckoDriver.prototype.switchToWindow = function*(cmd, resp) {
   let switchTo = cmd.parameters.name;
-  let isB2G = this.appName == "B2G";
+  let isMobile = this.appName == "B2G" || this.appName == "Fennec";
   let found;
 
   let getOuterWindowId = function(win) {
     let rv = win.QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsIDOMWindowUtils)
         .outerWindowID;
-    rv += isB2G ? "-b2g" : "";
+    rv += isMobile ? "-b2g" : "";
     return rv;
   };
 
   let byNameOrId = function(name, outerId, contentWindowId) {
     return switchTo == name ||
         switchTo == contentWindowId ||
         switchTo == outerId;
   };
 
   let winEn = this.getWinEnumerator();
   while (winEn.hasMoreElements()) {
     let win = winEn.getNext();
     let outerId = getOuterWindowId(win);
 
-    if (win.gBrowser && !isB2G) {
+    if (win.gBrowser && !isMobile) {
       let tabbrowser = win.gBrowser;
       for (let i = 0; i < tabbrowser.browsers.length; ++i) {
         let browser = tabbrowser.getBrowserAtIndex(i);
         let contentWindowId = this.getIdForBrowser(browser);
         if (byNameOrId(win.name, contentWindowId, outerId)) {
           found = {
             win: win,
             outerId: outerId,
@@ -3034,17 +3034,21 @@ var BrowserObj = function(win, driver) {
   this.updateIdForBrowser = driver.updateIdForBrowser.bind(driver);
   this._curFrameId = null;
   this._browserWasRemote = null;
   this._hasRemotenessChange = false;
 };
 
 Object.defineProperty(BrowserObj.prototype, "browserForTab", {
   get() {
-    return this.browser.getBrowserForTab(this.tab);
+    if (this.browser.getBrowserForTab) {
+      return this.browser.getBrowserForTab(this.tab);
+    } else {
+      return this.browser.selectedBrowser;
+    }
   }
 });
 
 /**
  * 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 within BrowserObject by a tab.
  */
@@ -3137,20 +3141,21 @@ BrowserObj.prototype.addTab = function(u
  * If a window is provided, this BrowserObj's internal reference is updated
  * before proceeding.
  */
 BrowserObj.prototype.switchToTab = function(ind, win) {
   if (win) {
     this.window = win;
     this.setBrowser(win);
   }
-
-  this.browser.selectTabAtIndex(ind);
+  if (this.browser.selectTabAtIndex) {
+    this.browser.selectTabAtIndex(ind);
+    this._browserWasRemote = this.browserForTab.isRemoteBrowser;
+  }
   this.tab = this.browser.selectedTab;
-  this._browserWasRemote = this.browserForTab.isRemoteBrowser;
   this._hasRemotenessChange = false;
 };
 
 /**
  * Registers a new frame, and sets its current frame id to this frame
  * if it is not already assigned, and if a) we already have a session
  * or b) we're starting a new session and it is the right start frame.
  *